Compare commits

..

207 Commits

Author SHA1 Message Date
Joe Haddad
fb4d4b5953 Publish Stable
- @now/build-utils@2.1.0
 - @now/next@2.4.0
 - @now/routing-utils@1.7.0
2020-02-28 10:19:47 -05:00
Joe Haddad
de3701c045 Publish Canary
- @now/ruby@1.0.3-canary.1
2020-02-28 10:18:46 -05:00
m5o
9f9b7934cb [now-ruby] Fix ruby test indentation (#3854)
* fix ruby indentation example
  * 💅 indent with 2 spaces for consistency
2020-02-28 14:34:47 +00:00
Steven
bcded1dd17 Publish Canary
- @now/build-utils@2.0.1-canary.3
 - @now/next@2.3.19-canary.2
 - @now/python@1.1.5-canary.1
2020-02-28 08:57:36 -05:00
Steven
8503af75ba [now-python] Fix space encoding 2020-02-28 08:35:27 -05:00
Joe Haddad
158a50f1aa [now-next] Allow Immutable Fallback Artifact (#3850)
* [now-next] Allow Immutable Fallback Artifact

* trigger
2020-02-27 22:00:09 -05:00
Steven
61da552dd6 [now-build-utils] Add test for NODE_ENV behavior (#3852)
This PR adds a test for #3847.
2020-02-27 21:47:27 +00:00
Steven
fa838eecac Publish Canary
- @now/go@1.0.5-canary.0
 - @now/next@2.3.19-canary.1
 - @now/node@1.4.2-canary.0
 - @now/python@1.1.5-canary.0
 - @now/ruby@1.0.3-canary.0
 - @now/static-build@0.14.13-canary.1
2020-02-27 15:52:36 -05:00
Steven
71b6a58783 [all] Exclude @now/build-utils in bundled builder to fix tests (#3848)
This fixes a bug in our `@now/build-utils` tests that pair the current build-utils with a stable builder. Since ncc was bundling `@now/build-utils`, we weren't able to configure a different version and these tests were not actually testing the correct version of build-utils.

A nice side-effect is that each builder will be about 50% smaller (compared by measuring `dist`).
2020-02-27 15:48:03 -05:00
Joe Haddad
22dd78e286 Publish Canary
- @now/build-utils@2.0.1-canary.2
 - @now/next@2.3.19-canary.0
2020-02-27 12:35:52 -05:00
Joe Haddad
e63fcf2630 [now-next] Add Support for Prerender v2 (#3845)
* [now-next] Add Support for Prerender v2

* Copy test suite

* Test that fallback doesn't work for fallback: false

* record omitted lambdas

* Improve test case

* improve omitted routes logic

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-02-27 12:33:31 -05:00
Steven
98e1553c2e [now-build-utils] Install all deps regardless of NODE_ENV (#3847)
Some build utilities and SSG Frameworks instruct users to set `NODE_ENV=production` which typically means updating `now.json` to the following:

```json
{
  "build": {
    "env": {
      "NODE_ENV": "production"
    }
  }
}
```

The problem is that this environment variable is assigned during `npm install` or `yarn install` which is the equivalent of running install with the `--production` flag. This flag prevents `devDependencies` from installing. This is almost never what the user intends so they have to remove `now.json` and instead updating their build script to `NODE_ENV=production yarn build`.

This PR improves the experience by deleting `NODE_ENV` during the install step.
2020-02-27 12:14:06 -05:00
Steven
4dc506f17a Publish Canary
- @now/build-utils@2.0.1-canary.1
 - now@17.0.5-canary.5
 - @now/routing-utils@1.6.1-canary.1
2020-02-27 08:05:05 -05:00
Steven
3b396f29e9 [now-build-utils][now-routing-utils] Fix appendRoutesToPhase() when input is null (#3843)
This PR fixes `@now/routing-utils` when the input routes are null. It used to return the empty array but now it will still append.

I also added many more tests to `@now/build-utils` when `featureHandleMiss: true` and refactored the code a bit to make dynamic routes and api routes a little more clear.
2020-02-26 23:30:50 +00:00
JJ Kasper
1f128e69e6 Publish Stable
- @now/next@2.3.18
2020-02-26 15:56:41 -06:00
JJ Kasper
f1487c92cb Publish Canary
- now@17.0.5-canary.4
 - @now/next@2.3.18-canary.0
2020-02-26 15:51:27 -06:00
JJ Kasper
45066cdf44 [now-next] Add /_next/data routes for getServerProps pages (#3771)
This adds the `/_next/data` routes for `getServerProps` pages if they exist

x-ref: https://github.com/zeit/next.js/pull/10077
x-ref: https://github.com/zeit/next.js/pull/10622
2020-02-26 21:47:51 +00:00
Ana Trajkovska
7dde9c8207 Publish Canary
- now@17.0.5-canary.3
 - now-client@7.0.1-canary.1
2020-02-26 08:00:09 +01:00
Ana Trajkovska
fd964f825d Handle deployment cancellation (#3823)
Co-authored-by: Max <8418866+rdev@users.noreply.github.com>
2020-02-26 07:21:27 +01:00
Steven
1656c9874e Publish Canary
- @now/build-utils@2.0.1-canary.0
 - now@17.0.5-canary.2
 - @now/routing-utils@1.6.1-canary.0
2020-02-25 17:32:37 -05:00
Steven
d999a3b2ad [now-routing-utils][now-build-utils] Refactor zero-config rewrites (#3832)
This PR refactors the rewrites (the dynamic routes as well as the route that prevents directory listing for zero config deployments) so they are not in the `handle: miss` phase.

This is necessary because the behavior of `handle: miss` will change in an upcoming release.

The solution is to separate these into `rewriteRoutes` that can then be merged properly with the user's routes. They will be appended to the `handle: filesystem` phase (or add the phase if it doesn't exist).
2020-02-25 22:30:36 +00:00
Joe Haddad
cfb7c9e632 Publish Stable
- @now/next@2.3.17
2020-02-25 15:19:05 -05:00
Joe Haddad
06e8472cf7 Publish Canary
- now@17.0.5-canary.1
 - @now/next@2.3.17-canary.0
 - @now/static-build@0.14.13-canary.0
2020-02-25 14:57:42 -05:00
Joe Haddad
92404135d8 [now-next] Always Emit Prerenders (#3837)
This ensures we always emit Prerender objects for bypass tokens.
2020-02-25 19:51:07 +00:00
Nathan Rajlich
8b5cc23d7c [now-cli] Remove v1 "static build" integration tests (#3833)
* [now-cli] Remove v1 "static build" integration tests

These are the last remaining v1 static type deployments being created.

* Remove from `integration.js` as well

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-02-24 17:19:22 -08:00
Shu Uesugi
e10b42bfdc Rename zeit.co/new → zeit.co/import (#3834)
* zeit.co/new → zeit.co/import

* Update docs URL
2020-02-25 01:35:12 +01:00
M. Heide
36f7ec4836 [examples] Fix Go build if Windows Git is configured to checkout CRLF line endings (#3821)
Fixes #3820
2020-02-24 19:53:15 +00:00
Joe Haddad
f89d1c463e Remove Backticks from URL Output (#3830)
![image](https://user-images.githubusercontent.com/616428/75176976-44434880-5703-11ea-8ca5-cb49e4a921cf.png)

![image](https://user-images.githubusercontent.com/616428/75176982-473e3900-5703-11ea-90f6-b31844a486ce.png)
2020-02-24 19:22:58 +00:00
Steven
5dc652eba9 Publish Canary
- now@17.0.5-canary.0
 - now-client@7.0.1-canary.0
2020-02-24 12:53:13 -05:00
Steven
821b2bd50b [now-client] Fix root directory with trailing slash (#3827)
There was a bug in `now-client` when deploying a directory that ends with a slash, for example `/Users/styfle/Code/myapp/` instead of the usual `/Users/styfle/Code/myapp`.

This never affected `now-cli` until we added support for defining the `rootDirectory` which allows the user to type whatever they wish in the Project Settings.

The fix is to use `path.relative()` instead of substring.
2020-02-24 17:45:10 +00:00
Steven
8d5f6f1fa3 Publish Stable
- @now/frameworks@0.0.10
 - @now/build-utils@2.0.0
 - now@17.0.4
 - @now/go@1.0.4
 - @now/next@2.3.16
 - @now/python@1.1.4
 - @now/routing-utils@1.6.0
2020-02-21 18:09:20 -05:00
Steven
617f610c07 [tests] Update cancel workflow (#3817)
Update to latest version, [0.2.0](https://github.com/styfle/cancel-workflow-action/releases/tag/0.2.0), which will fix cancelling on push.

Also this action is available in the [marketplace](https://github.com/marketplace/actions/cancel-workflow-action).
2020-02-21 18:00:27 -05:00
Steven
3229ba0106 Publish Canary
- @now/go@1.0.4-canary.3
 - @now/python@1.1.4-canary.1
2020-02-21 17:27:20 -05:00
Steven
d16a6e4716 [now-go] Fix path segments in now dev (#3816)
The combination of file renaming and brackets doesn't work well for go build so we need to add the file extension back before building.

I also simplified the `.now/cache/folder` logic because it should be the same whether `builds` is defined or not (aka zero config).
2020-02-21 22:25:44 +00:00
Steven
4e5156fb0b [now-python] Fix path segments in now dev (#3815)
The combination of file renaming and brackets doesn't work well for python imports so we need too add the file extension back before importing the python module.

I also simplified the `.now/cache/folder` logic because it should be the same whether `builds` is defined or not (aka zero config).
2020-02-21 20:45:41 +00:00
Joe Haddad
3c013cc36b Publish Canary
- @now/build-utils@2.0.0-canary.2
 - @now/next@2.3.16-canary.1
2020-02-21 11:06:44 -05:00
Joe Haddad
1ed83135be Add Bypass Token to Next.js Builder (#3811)
This pull request adds the bypass token to returned `Prerender` output objects.

There's no tests as this doesn't exist in production yet.
2020-02-21 16:05:22 +00:00
Joe Haddad
0e71ff2df1 [now-build-utils] Add bypassToken to Prerender for iSSG (#3810)
This pull request adds a new `bypassToken` field to the `Prerender` output.

The field is required to be at least 128 bits for security reasons!
2020-02-20 01:59:45 +00:00
JJ Kasper
d8e98ee476 Publish Canary
- @now/next@2.3.16-canary.0
 - @now/routing-utils@1.5.4-canary.0
2020-02-19 16:23:25 -06:00
JJ Kasper
1bc1e8a9b1 [now-routing-utils] Update to not pass used segments in redirect query (#3809)
This updates to not pass segments already used in a redirect's destination query since these values are most likely unwanted and can still be manually added if desired. This change does not affect rewrites and we still pass through all segments in the query
2020-02-19 22:13:36 +00:00
JJ Kasper
274fdeb49a Publish Stable
- @now/next@2.3.15
2020-02-19 15:02:21 -06:00
JJ Kasper
d15c90b42f Publish Canary
- now@17.0.4-canary.3
 - @now/next@2.3.15-canary.0
2020-02-19 14:57:20 -06:00
JJ Kasper
5be2917c47 [now-next] Update 404 handling for pages/404 (#3697)
This adds handling for treating `pages/404.js` as the custom error page in Next.js to allow for more flexible auto static optimization on the 404 page. This makes sure we handle `pages/404.js` being a lambda due to `_app` having `getInitialProps` and also makes sure that visiting `/404` doesn't respond with a 200 status code

~We can add tests for this behavior after the below PR has been released in a canary of Next.js~

x-ref: https://github.com/zeit/next.js/pull/10329
x-ref: https://github.com/zeit/next.js/pull/10593
2020-02-19 20:55:26 +00:00
dependabot[bot]
5f08b24546 Bump codecov from 3.1.0 to 3.6.5 (#3807)
Bumps [codecov](https://github.com/codecov/codecov-node) from 3.1.0 to 3.6.5.
<details>
<summary>Release notes</summary>

*Sourced from [codecov's releases](https://github.com/codecov/codecov-node/releases).*

> ## v3.6.4
> Fix for Cirrus CI
> 
> ## v3.6.3
> AWS Codebuild fixes + package updates
> 
> ## v3.6.2
> command line args sanitised
> 
> ## v3.6.1
> Fix for Semaphore
> 
> ## v3.6.0
> AWS CodeBuild
> Semaphore v2
> 
> ## v3.3.0
> Added pipe `--pipe`, `-l`
</details>
<details>
<summary>Commits</summary>

- See full diff in [compare view](https://github.com/codecov/codecov-node/commits)
</details>
<details>
<summary>Maintainer changes</summary>

This version was pushed to npm by [drazisil](https://www.npmjs.com/~drazisil), a new releaser for codecov since your current version.
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=codecov&package-manager=npm_and_yarn&previous-version=3.1.0&new-version=3.6.5)](https://help.github.com/articles/configuring-automated-security-fixes)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/zeit/now/network/alerts).

</details>
2020-02-19 20:19:49 +00:00
Steven
cc3026ffcb [tests] Fix builder debug flag (#3805)
When testing, you can set `NOW_BUILDER_DEBUG=1` to print verbose logs from builders.

However, this was causing some tests to fail that depended on a build environment variable.

This PR fixes the assignment so that it preserves the environment variables from the tests by adding `NOW_BUILDER_DEBUG` instead of replacing.
2020-02-18 22:57:17 +00:00
JJ Kasper
8cb6e56679 Publish Stable
- @now/next@2.3.14
2020-02-17 14:28:07 -06:00
JJ Kasper
7da5ff4b1d Publish Canary
- now@17.0.4-canary.2
 - @now/next@2.3.14-canary.1
2020-02-17 11:45:53 -06:00
JJ Kasper
5d1069d464 [now-next] Make sure to 404 and clear cache header for invalid _next requests (#3801)
This handles an edge case where deeply nested dynamic routes were handling `_next` 404s that were cached forever since the immutable header we set isn't cleared after not matching on the filesystem.

I updated our cache-header fixture to check for this edge case also to make sure we don't regress on this
2020-02-17 17:42:51 +00:00
Andy
6e1a72f557 [examples] Use Full URL for Logos (#3800)
Use Full URL for Logos

[PRODUCT-1193]

[PRODUCT-1193]: https://zeit.atlassian.net/browse/PRODUCT-1193
2020-02-17 13:44:35 +00:00
dependabot[bot]
6f97a2cc7a Bump yarn from 1.17.3 to 1.22.0 (#3796)
Bumps [yarn](https://github.com/yarnpkg/yarn) from 1.17.3 to 1.22.0.
<details>
<summary>Changelog</summary>

*Sourced from [yarn's changelog](https://github.com/yarnpkg/yarn/blob/master/CHANGELOG.md).*

> # Changelog
> 
> Please add one entry in this file for each change in Yarn's behavior. Use the same format for all entries, including the third-person verb. Make sure you don't add more than one line of text to keep it clean. Thanks!
> 
> ## Master
> 
> - Passes arguments following `--` when running a workspace script (`yarn workspace pkg run command -- arg`)
> 
>   [#7776](https://github-redirect.dependabot.com/yarnpkg/yarn/pull/7776) - [**Jeff Valore**](https://twitter.com/rally25rs)
> 
> - Prints workspace names with `yarn workspaces` (silence with `-s`)
> 
>   [#7722](https://github-redirect.dependabot.com/yarnpkg/yarn/pull/7722) - [**Orta**](https://twitter.com/orta)
> 
> - Implements `yarn init --install <version>`
> 
>   [#7723](https://github-redirect.dependabot.com/yarnpkg/yarn/pull/7723) - [**Maël Nison**](https://twitter.com/arcanis)
>   
> - Implements `yarn init -2`
> 
>   [#7862](https://github-redirect.dependabot.com/yarnpkg/yarn/pull/7862) - [**Maël Nison**](https://twitter.com/arcanis)
> 
> - Implements `yarn set version <version>` as an alias for `policies set-version`
> 
>   [#7862](https://github-redirect.dependabot.com/yarnpkg/yarn/pull/7862) - [**Maël Nison**](https://twitter.com/arcanis)
> 
> - Fixes an issue where the archive paths were incorrectly sanitized
> 
>   [#7831](https://github-redirect.dependabot.com/yarnpkg/yarn/pull/7831) - [**Maël Nison**](https://twitter.com/arcanis)
> 
> - Allows some dots in binary names again
> 
>   [#7811](https://github-redirect.dependabot.com/yarnpkg/yarn/pull/7811) - [**Valery Bugakov**](https://github.com/valerybugakov)
>   
> - Better error handling on `yarn set version`
> 
>   [#7848](https://github-redirect.dependabot.com/yarnpkg/yarn/pull/7848) - [**Nick Olinger**](https://github.com/olingern)
> 
> ## 1.19.2
> 
> - Folders like `.cache` won't be pruned from the `node_modules` after each install.
> 
>   [#7699](https://github-redirect.dependabot.com/yarnpkg/yarn/pull/7699) - [**Maël Nison**](https://twitter.com/arcanis)
> 
> - Correctly installs workspace child dependencies when workspace child not symlinked to root.
> 
>   [#7289](https://github-redirect.dependabot.com/yarnpkg/yarn/pull/7289) - [**Daniel Tschinder**](https://github.com/danez)
> 
> - Makes running scripts with Plug'n Play possible on node 13.
> 
></tr></table> ... (truncated)
</details>
<details>
<summary>Commits</summary>

- [`eee67d0`](eee67d02ed) v1.22.0
- [`6971622`](69716228e9) Update CHANGELOG.md
- [`0e7133c`](0e7133ca28) Fixes arbitrary file write on fetch ([#7831](https://github-redirect.dependabot.com/yarnpkg/yarn/issues/7831))
- [`fa613f3`](fa613f3a71) handle failed policy set-version ([#7848](https://github-redirect.dependabot.com/yarnpkg/yarn/issues/7848))
- [`f381c5f`](f381c5f0ce) Implements set version ([#7862](https://github-redirect.dependabot.com/yarnpkg/yarn/issues/7862))
- [`d2c3a48`](d2c3a485e0) Configure bug report issue template ([#7844](https://github-redirect.dependabot.com/yarnpkg/yarn/issues/7844))
- [`af4c205`](af4c2056a3) Allow dots in bin names ([#7811](https://github-redirect.dependabot.com/yarnpkg/yarn/issues/7811))
- [`1b334e6`](1b334e687b) fix(workspaces): Pass args following "--" when running workspace scripts ([#7786](https://github-redirect.dependabot.com/yarnpkg/yarn/issues/7786))
- [`2c8e97e`](2c8e97eaf3) Fix suggestions for CLI ([#7808](https://github-redirect.dependabot.com/yarnpkg/yarn/issues/7808))
- [`039bafd`](039bafd74b) Fixes bin overwrites ([#7755](https://github-redirect.dependabot.com/yarnpkg/yarn/issues/7755))
- Additional commits viewable in [compare view](https://github.com/yarnpkg/yarn/compare/v1.17.3...v1.22.0)
</details>
<details>
<summary>Maintainer changes</summary>

This version was pushed to npm by [daniel15](https://www.npmjs.com/~daniel15), a new releaser for yarn since your current version.
</details>
<br />

[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=yarn&package-manager=npm_and_yarn&previous-version=1.17.3&new-version=1.22.0)](https://help.github.com/articles/configuring-automated-security-fixes)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
- `@dependabot use these labels` will set the current labels as the default for future PRs for this repo and language
- `@dependabot use these reviewers` will set the current reviewers as the default for future PRs for this repo and language
- `@dependabot use these assignees` will set the current assignees as the default for future PRs for this repo and language
- `@dependabot use this milestone` will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the [Security Alerts page](https://github.com/zeit/now/network/alerts).

</details>
2020-02-15 01:56:34 +00:00
Steven
6e402bffc3 Publish Canary
- now@17.0.4-canary.1
 - @now/go@1.0.4-canary.2
 - @now/next@2.3.14-canary.0
2020-02-14 15:05:00 -05:00
Steven
e41d0f8e68 [now-go] Fix /api/go.sum detection (#3795)
Follow up to #3793 

The `go.mod` and `go.sum` file must both be moved.
2020-02-14 19:58:44 +00:00
Steven
1a046744f2 [now-go] Add support for root go.mod in api directory (#3793)
Some users wish to put all Go related code in the `/api` directory and the root is reserved for a frontend framework.

This PR adds support for `/api/go.mod` which will act the same as `/go.mod` by moving the file to the root.
2020-02-14 17:32:20 +00:00
Andy
a9bf011f2c [api] Add rewrite to frameworks API (#3794)
* [api] Add rewrite to frameworks API

* Adjust now.json

* Change output file
2020-02-14 00:30:58 +01:00
JJ Kasper
60c76b3290 [now-next] Add support for using the fallback file for dynamic SSG pages (#3752)
This adds support for using the fallback file for dynamic (lazy) SSG pages to allow showing a loading state while the cache is populated with data. We can add tests for this behavior once the below referenced PR is shipped on canary

x-ref: https://github.com/zeit/next.js/pull/10424

~Update: added tests now that fallback support has landed in Next.js although it appears `now-proxy` might need to be updated to revalidate the fallback correctly since the initial fallback is always being shown for lazy SSG pages with these changes~

Looks like this is working properly in `now-proxy` and we were overriding the prerender output with the static page output, thanks @juancampa for helping investigate! 🙏
2020-02-13 01:06:55 +00:00
Steven
c7ff1e7044 [now-cli] Update ZEIT Logo (#3790)
This PR updates the logo to match https://zeit.co/home
2020-02-12 10:17:54 -05:00
Andy Bitz
e2deaef54a Publish Canary
- @now/frameworks@0.0.10-canary.0
2020-02-12 14:46:11 +01:00
Andy
b2c7386c83 [frameworks] Adjust Next.js build command placeholder (#3788) 2020-02-12 14:34:09 +01:00
Steven
3dce84c3cf Publish Canary
- @now/go@1.0.4-canary.1
2020-02-11 16:46:21 -05:00
Steven
443b1ac158 [now-go] Fix path segments with square brackets (#3782)
Previously, `@now/go` would fail when using [Path Segments](https://zeit.co/docs/v2/serverless-functions/introduction#path-segments) since `go build` [doesn't support](https://stackoverflow.com/q/60140859/266535) files that begin with square bracket.

This PR changes the build logic so that the entrypoint file is renamed if if begins with a square bracket.

The output file is not renamed because v3 builders can't rename outputs which works great for this feature.
2020-02-11 21:41:57 +00:00
Andy Bitz
be3dca3d94 Publish Canary
- @now/build-utils@2.0.0-canary.1
 - now@17.0.4-canary.0
 - @now/go@1.0.4-canary.0
 - @now/python@1.1.4-canary.0
2020-02-11 16:50:13 +01:00
Andy Bitz
cb135e4329 [now-build-utils] Bump version 2020-02-11 16:50:01 +01:00
Andy
55c73b68bb [now-build-utils][now-cli] Refactor builds and routes detection (#3784)
* [now-build-utils] Refactor detect builds

* Refactor routes detection

* [now-cli] Adjust `now dev`

* Adjust tests

* Adjust integrations test

* Remove unused file

* Replace reducw with for-loop

* Add cache for absolute paths

* Filter while looping

* Add fallback for entrypoint with buildCommand
2020-02-11 16:47:39 +01:00
Steven
eb793ba139 [tests] Add windows to CI unit tests (#3727)
This adds initial support for Windows in GitHub Actions CI tests.

There is still work to be done to prevent certain tests from hanging in CI so those are skipped for now.
2020-02-11 01:16:14 +00:00
Steven
00908e8ebe [now-python] Fix path segments with square brackets (#3781)
Previously, python would fail when using [Path Segments](https://zeit.co/docs/v2/serverless-functions/introduction#path-segments) as seen in #3729.

This PR changes the import logic so that the entrypoint file is [imported as a relative file path](https://stackoverflow.com/a/67692/266535) instead of by module name.
2020-02-10 21:01:31 +00:00
Leo Lamprecht
5ce7ff86a4 Minor tweaks for CONTRIBUTING.md file (#3778)
* Minor tweaks for CONTRIBUTING.md file

* Update CONTRIBUTING.md

* Update CONTRIBUTING.md
2020-02-10 18:34:00 +01:00
Steven
4b34ee2993 [examples] Remove outdated jekyll build section from README (#3780)
We used to require a `package.json` but we have since introduced [Advanced Project Settings](https://zeit.co/blog/advanced-project-settings) which will ask the user for a build command during the first deploy.
2020-02-10 15:31:52 +00:00
Andi
646bd288ba [now-go] Update go to version 1.13.7 (#3750)
Updates go to the latest version 1.13.7 (https://golang.org/doc/devel/release.html#go1.13). This allows users to use the new error functionality that was introduced in go 1.13 (https://blog.golang.org/go1.13-errors) and also includes a couple of security fixes.

Looking at the last PR that updated the version (https://github.com/zeit/now-builders/pull/247/files) this should be as simple as updating the version number.

P.S. I tried to follow the contribution guidelines, but `yarn lint` fails with `exit code 1`/`295 problems (33 errors, 262 warnings)` and `yarn test` returns `error Command "test" not found` on master. But `yarn test-unit` shows no errors.
2020-02-08 01:47:47 +00:00
Steven
8aba6f1ff8 Publish Stable
- now@17.0.3
2020-02-07 20:01:17 -05:00
Steven
35e5e328aa Publish Canary
- now@17.0.3-canary.1
2020-02-07 19:18:47 -05:00
Andy
bdd4953d62 [now-cli] Consider root directory for now.json (#3764)
* [now-cli] Consider root directory for now.json

* Adjust message check in test

* Fallback if config does not exist as well

* Assign localConfig later and add debug

* Prefere now.json from root directory

* Comment

* Adjust test and add warning
2020-02-08 01:04:34 +01:00
Steven
e938b298e2 [now-cli] Fix port assignment for now dev (#3769)
This fixes a regression from #3749 where the PORT env var was removed. This is necessary so frameworks like create-react-app and gatsby can proxy to `now dev`.

Fixes #3761
2020-02-07 19:03:56 -05:00
Andy
b67f324e10 [api] Add hasDetectors property (#3770) 2020-02-08 00:29:11 +01:00
Andy Bitz
1dfa286af5 Publish Canary
- now@17.0.3-canary.0
2020-02-07 21:14:50 +01:00
Andy
d4391bd4cc [now-cli] Fix chalk template for legacy (#3768)
* [now-cli] Fix chalk template for legacy

* Update packages/now-cli/src/commands/deploy/legacy.ts

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

Co-authored-by: Nathan Rajlich <n@n8.io>
2020-02-07 21:14:11 +01:00
luc
53eb71f26d Publish Stable
- now@17.0.2
 - @now/routing-utils@1.5.3
2020-02-06 19:18:35 +01:00
luc
92ffd654b5 Publish Canary
- now@17.0.2-canary.1
2020-02-06 18:53:36 +01:00
Luc
36b83f1606 [now-cli] Use npx or yarn to execute dev command (#3760)
1. Use bundled yarn to run `yarn bin`
2. Skip `yarn bin` if `npx` is used
2020-02-06 17:47:39 +00:00
Steven
7a79f620c0 [tests] Fix changelog script (#3751)
Previously, the changelog script was looking for the last "Publish Stable" commit, but it should really be looking for the last Stable release of Now CLI.

This PR updates the changelog script so that it fetches the latest GH Release (which should be Now CLI) and then compares that to the HEAD.
2020-02-06 14:35:15 +00:00
Steven
f3b286ecf3 Publish Canary
- now@17.0.2-canary.0
 - @now/routing-utils@1.5.3-canary.0
2020-02-06 09:12:19 -05:00
Steven
adf31c3fcc [now-routing-utils] Change behavior of trailingSlash: true redirects (#3745)
This PR changes the behavior of `trailingSlash: true` after we received feedback that files should not be redirected with a trailing slash. This matches the behavior of `serve` and `serve-handler`.

### Examples 
* `/index.html` => serve
* `/assets/style.css` => serve
* `/assets` => redirect to `/assets/`
* `/assets/style` => redirect to `/assets/style/` 

### Additional

In order to avoid duplicate content, this PR also adds redirects to files without a trailing slash.

* `/about.html/` => redirect to `/about.html`
* `/assets/style.css/` => redirect to `/assets/style.css`


Fixes #3731
2020-02-06 09:07:46 -05:00
luc
deacdfc47c Publish Stable
- now@17.0.1
2020-02-06 01:07:15 +01:00
Luc
ac9badbe9e [now-cli] Always output deployment url in stdout (#3753) 2020-02-06 00:58:24 +01:00
luc
62beb0f78d Publish Stable
- @now/frameworks@0.0.9
 - @now/build-utils@1.3.9
 - @now/cgi@1.0.3
 - now@17.0.0
 - now-client@7.0.0
 - @now/go@1.0.3
 - @now/next@2.3.13
 - @now/node@1.4.1
 - @now/python@1.1.3
 - @now/routing-utils@1.5.2
 - @now/ruby@1.0.2
 - @now/static-build@0.14.12
2020-02-05 23:03:23 +01:00
luc
5f9777f4af Publish Canary
- now@17.0.0-canary.35
2020-02-05 22:38:39 +01:00
Luc
e00db4437a [now-cli] Use npx when available to run dev command (#3749)
* use npx when available

* add --no-install

* replace $PORT and %PORT% in devCommand

* remove PORT from env variables

* replace more than one $PORT or %PORT%

* fix regex
2020-02-05 22:37:06 +01:00
Steven
b0e4f2590d Publish Stable
- @now/cgi@1.0.2
 - @now/go@1.0.2
 - @now/python@1.1.2
2020-02-05 15:09:14 -05:00
Leo Lamprecht
f0d58eac8c Remove now dev suggestion (#3748) 2020-02-05 20:50:21 +01:00
Steven
dae830d2b6 [examples] Fix hugo theme (#3746)
The Hugo theme was lost when transferring from `zeit/now-examples` to `zeit/now`.

This PR fixes the `.gitignore` file to include the `dist` directory and override our root `.gitignore`.
2020-02-05 19:30:08 +00:00
dependabot[bot]
e3071e4e29 Bump mixin-deep from 1.3.1 to 1.3.2 in /packages/now-cgi (#3736)
Bumps [mixin-deep](https://github.com/jonschlinkert/mixin-deep) from 1.3.1 to 1.3.2.
- [Release notes](https://github.com/jonschlinkert/mixin-deep/releases)
- [Commits](https://github.com/jonschlinkert/mixin-deep/compare/1.3.1...1.3.2)

Signed-off-by: dependabot[bot] <support@github.com>
2020-02-05 09:52:08 -05:00
Steven
073d7ece23 Publish Canary
- @now/build-utils@1.3.9-canary.0
 - now@17.0.0-canary.34
2020-02-05 08:29:10 -05:00
Andy Bitz
071258ba33 Publish Stable
- @now/build-utils@1.3.8
2020-02-05 03:27:31 +01:00
Andy
c0e00dc69a [now-build-utils] Fix build script check (#3743) 2020-02-05 03:27:17 +01:00
luc
6e5c136337 Publish Canary
- now@17.0.0-canary.33
2020-02-05 02:26:53 +01:00
Steven
60428cd4cf [now-cli] Bump @zeit/fun to 0.11.2 (#3741)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-02-05 02:20:54 +01:00
Luc
c6b9d80eec Fix now cli breaking tests (#3742) 2020-02-05 02:17:43 +01:00
Luc
953bdc10e5 [now-cli] Fix prompts and fetch team on windows (#3740)
* fix fetch on windows

* update inquirer

Co-authored-by: Leo Lamprecht <mindrun@icloud.com>
2020-02-05 01:58:49 +01:00
Andy Bitz
becdbd2136 Publish Stable
- @now/build-utils@1.3.7
2020-02-05 01:52:02 +01:00
Luc
da9bb31259 [now-cli] Handle no framework detected case (#3738)
* handle no framework detected case

* remove related test

* simplify

Co-authored-by: Leo Lamprecht <mindrun@icloud.com>
2020-02-05 01:49:13 +01:00
Luc
8cbf036921 [now-cli] Do not prompt for root directory when project is linked (#3737)
* do not prompt for root directory when linked

* run tests

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
Co-authored-by: Leo Lamprecht <mindrun@icloud.com>
2020-02-05 01:48:52 +01:00
Andy
8f66e4a308 [now-build-utils] Handle empty buildCommand and outputDirectory (#3739)
* [now-build-utils] Handle empty buildCommand and outputDirectory

* Update comment
2020-02-05 01:47:54 +01:00
Luc
9627b612f2 [now-cli] Do not show spinners with --debug (#3732)
* create output.wait and use it

* fix printing "ended" multiple times

* update more `wait` -> `output.spinner`

* timeout -> delay
2020-02-04 23:23:37 +01:00
Luc
8a9ded6d61 [now-cli] Slugify suggested project name (#3733)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-02-04 22:29:07 +01:00
Steven
d89c772bd5 [now-build-utils] Exclude _test.go files (#3735)
Typically, Go tests are side-by-side with their source files in a `_test.go`.

The Go documentation says the following:

> To write a new test suite, create a file whose name ends _test.go that contains the TestXxx functions as described here. Put the file in the same package as the one being tested. The file will be excluded from regular package builds but will be included when the “go test” command is run. [View Docs](https://golang.org/pkg/testing/)

This PR excludes the test files from being turned into Serverless Functions.
2020-02-04 21:11:26 +00:00
Steven
32137586b9 Publish Stable
- @now/static-build@0.14.11
2020-02-04 15:10:33 -05:00
Andy Bitz
9a3e435175 Publish Stable
- @now/frameworks@0.0.8
2020-02-04 21:06:30 +01:00
Andy
01d5a10ebd [@now/frameworks] Add Other (#3734)
* [@now/frameworks] Add Other

* Add logo

* Fix typo

* Add description
2020-02-04 21:03:56 +01:00
Steven
040658fbfa Publish Canary
- now@17.0.0-canary.32
 - @now/go@1.0.2-canary.0
2020-02-03 19:43:39 -05:00
Steven
51c00286a4 [now-go] Fix now dev on Windows (#3730) 2020-02-03 19:40:41 -05:00
Steven
c3e274fc2f [now-cli] Fix now dev when api file is added or removed (#3708)
This PR is a follow up to #3703 which fixes file output renaming on initial boot but not when files are added or removed while `now dev` is running. This PR fixes that behavior.
2020-02-03 16:30:37 -05:00
Steven
fe633c528a Publish Canary
- now@17.0.0-canary.31
 - @now/static-build@0.14.11-canary.2
2020-02-03 13:28:43 -05:00
Steven
5e306d49f8 [now-static-build] Fix error when HUGO_VERSION not found (#3724)
This PR improves the error message when the user specifies a version but that version does not exist.

- HUGO_VERSION
- ZOLA_VERSION
- GUTENBERG_VERSION

Typically this means there is no tag for that particular version. It could also mean there is a tag but no binary is attached to the tag/release.

![image](https://user-images.githubusercontent.com/229881/73673953-900f4e80-467d-11ea-90ed-3317cf83c74e.png)

![image](https://user-images.githubusercontent.com/229881/73673985-9d2c3d80-467d-11ea-8ee4-cc6ecabaac20.png)

Related to [zeit/docs#1624](https://github.com/zeit/docs/pull/1624)
2020-02-03 13:21:11 -05:00
Steven
274259b7dd [tests] Update to use github action cancel workflow (#3720)
Removes script and instead uses proper GitHub Action.

This reduces the time to run from 10 seconds to 5 seconds (due to ncc).

https://github.com/styfle/cancel-workflow-action
2020-02-02 02:47:33 +00:00
Steven
230e96c687 [tests] Change warn to error on unsed vars (#3715)
Follow up to #3714 that turns the warning into an error.

![image](https://user-images.githubusercontent.com/229881/73582375-ea7c9500-445a-11ea-9d20-2a17073a068a.png)
2020-02-01 00:41:40 +00:00
Nathan Rajlich
8c0c6e546d [now-cli] Remove unused fs import (#3714)
Fixes GH pull request auto-lint:

> #### Check warning on line 2 in `packages/now-cli/src/util/input/input-root-directory.ts`:
>
> ## GitHub Actions / Unit Tests (ubuntu-latest, 12)
>
> `packages/now-cli/src/util/input/input-root-directory.ts#L2`
>
> ```
> 'fs' is defined but never used
> ```
2020-01-31 18:57:09 -05:00
Steven
5e8541b936 [tests] Don't run tests in forks (#3713)
There is no need to run the tests in a fork because when the forked repo submits a PR to this repo, the tests will run.
2020-01-31 18:49:56 -05:00
Simon Hänisch
300558f24e [now-static-build] Add caching headers for Stencil (#3493)
/cc @adamdbradley @leo
2020-01-31 23:48:46 +00:00
Steven
829f7d8aeb Publish Canary
- @now/build-utils@1.3.7-canary.2
 - @now/python@1.1.2-canary.0
2020-01-31 16:48:34 -05:00
Steven
340f7db68a [now-python] Add excludeFiles config option (#3712)
This PR adds a `config.excludeFiles` pattern for `@now/python` that defaults to `node_modules/**` for users who are using a Node.js SSG frontend with Python APIs backend.

If the user chooses, they can override to any glob pattern such as `{.cache,node_modules}/**`.

Related to #2830
Related to #3416
2020-01-31 21:47:14 +00:00
luc
2fe987b5da Publish Canary
- now@17.0.0-canary.30
2020-01-31 22:13:11 +01:00
Andy
5b3aa48cd6 [now-cli] Adjust error message for Root Directory (#3710)
* [now-cli] Adjust error message for Root Directory

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

Co-Authored-By: Luc <luc.leray@gmail.com>

Co-authored-by: Luc <luc.leray@gmail.com>
2020-01-31 21:36:06 +01:00
Steven
080d96bfa1 [api] Silence github comments (#3709)
Most PRs don't touch the examples api so let's silence the comments and cancel in-progress builds if we push again.

This should reduce the noise in this repository.

Documentation: https://zeit.co/docs/configuration#introduction/configuration-reference
2020-01-31 16:57:18 +00:00
Luc
7d9bf682b4 [now-cli] Add [copied to clipboard] (#3707) 2020-01-31 17:16:29 +01:00
Steven
a913a4f59f [tests] Cancel previous CI runs (#3706)
This PR adds an action to cancel previous runs for the current branch using the [github workflow api](https://developer.github.com/v3/actions/workflow_runs/).

This action is ignored for the `master` branch.
2020-01-31 09:30:09 -05:00
Andy Bitz
2042c96d98 Publish Canary
- now@17.0.0-canary.29
2020-01-31 13:30:12 +01:00
Steven
4ca0ff8426 [now-cli] Fix now dev file output renaming (#3703)
There was a bug where python src files were being renamed when it really should be the output files only.

This is a tricky bug because production deployments build all files first and then perform routing. So we simply rename lambda outputs with prod deployments. But `now dev` matches a request URL to a build before performing the build lazily so we have to rename source files.

The solution is to add both the original file name and the renamed file name in the `files` map so that it matches correctly but `zeit/fun` will still copy the original source files in the output correctly.

Routing will match on the extensionless file, the builder will use the file with extension (it doesn't know about file renaming), then the build results in a lambda output which is renamed to extensionless.

I added a test for `@now/python` and updated the `@now/bash` test.

Fixes #3638
2020-01-31 12:20:46 +00:00
Andy
554cc42d83 [now-cli] Add support for the rootDirectory property (#3686)
* [now-cli] Add support for the `rootDirectory` property

* Only check if rootDirectory exists

* Add test

* Support now dev

* Use defaults

* Comment

* Normalize the path input

* Adjust test

* Remove .only

* Adjust more tests

* Adjust test

* Fix test

* Remove unused import

* Update packages/now-cli/src/util/validate-paths.ts

Co-Authored-By: Luc <luc.leray@gmail.com>

* Run check on normalized path

* Add more checks

* Change error message

* Use basename as prefix

* Use correct path when linking

* Update packages/now-cli/src/util/input/input-root-directory.ts

Co-Authored-By: Luc <luc.leray@gmail.com>

Co-authored-by: Luc <luc.leray@gmail.com>
2020-01-31 12:56:09 +01:00
Steven
3f9e30d031 [docs] Update readme with CI status (#3704)
This repo no longer uses Circle CI since #3660 so this PR updates the badge in the readme.
2020-01-30 17:04:33 -05:00
luc
5a9ca8644c Publish Canary
- now@17.0.0-canary.28
2020-01-30 20:07:27 +01:00
Luc
3f362d4b50 [now-cli] Add scope indication to now secrets (#3699)
It looks like this:
![image](https://user-images.githubusercontent.com/6616955/73408935-03bbff00-42fe-11ea-9f1c-70860437c6bc.png)
2020-01-30 19:01:44 +00:00
Steven
7360886c9a [tests] Run unit tests on ubuntu and macos (#3702)
* [tests] Run unit tests on ubuntu and macos

* Add back Node 10 for Now CLI Tests

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-01-30 18:21:16 +01:00
Luc
5b8a1b47b0 [now-cli] Adjust name error messages (#3698)
* adjust `name` error messages

* return after outputting error
2020-01-30 18:10:44 +01:00
luc
0506b262d2 Publish Canary
- now@17.0.0-canary.27
2020-01-30 17:38:31 +01:00
Luc
17c4569f41 [now-cli] Send framework to api-deployments (#3701)
* send `framework` to api-deployments

* add error message

* Update packages/now-cli/src/util/input/edit-project-settings.ts

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

Co-authored-by: Steven <steven@ceriously.com>
2020-01-30 17:37:48 +01:00
Steven
888ff83309 Publish Stable
- @now/node@1.4.0
 - @now/python@1.1.1
2020-01-30 09:39:59 -05:00
Steven
7191421470 [tests] Fix rate limits for integration tests (#3696)
This PR will fix our CI rate limits for the "Now CLI Tests" check in GH Actions.

Thanks to @AndyBitz for most of the work in #3325
2020-01-29 16:24:02 -05:00
luc
e9c9aa5ce1 Publish Canary
- now@17.0.0-canary.26
2020-01-29 21:10:37 +01:00
Luc
d98f3d8140 [now-cli] Deprecate --name and now.json name property (#3690)
* remove `--name` from help

* add deprecation warning

* refactor

* deprecated `name` property in now.json

* add tests

* remove .only
2020-01-29 21:09:28 +01:00
Luc
fbf659e4e1 [now-cli] Add error message when running now dev on an unlinked folder (#3692)
* refactor getLinkedProject

* adjustments

* refactor getLinkedOrg

* refactor linkFolderToProject to skip linking

* fix dev tests

* adjust tests

* print deployment url for files

* fix missing `NOW_PROJECT_ID` check

* `process.status` -> `link.status`
2020-01-29 21:09:08 +01:00
Steven
6f7069aadd Publish Canary
- @now/python@1.1.1-canary.1
2020-01-29 13:26:41 -05:00
Steven
cef2c889f6 [now-python] Fix dependency detection in now dev (#3695)
Fixes a false positive regression from #3352 where `now dev`  assumed that local dependencies were already installed even when they were not.
2020-01-29 13:24:15 -05:00
Steven
e42d6c422a Publish Canary
- now@17.0.0-canary.25
 - @now/routing-utils@1.5.2-canary.4
2020-01-28 18:15:17 -05:00
Steven
2e9241b454 [now-routing-utils] Enabled case sensitive rewrites and set delimiter (#3688)
This enables case sensitive rewrites and redirects. It also changes the delimiter to `/` to match Next.js.

Unlike `routes` which were case insensitive, `rewrites` and `redirects` are case sensitive.

In the future, we may wish to add an option to toggle the sensitivity.
2020-01-28 18:13:57 -05:00
Steven
257a3b07fc [now-cli] Remove several v1 tests from CI (#3689)
These 5 tests are available in `integration-v1.js` already which can be executed manually.
2020-01-28 17:14:04 -05:00
luc
df9322b392 Publish Canary
- now@17.0.0-canary.24
2020-01-28 20:39:44 +01:00
Luc
28b5476bf3 [now-cli] Add link to "deploying files is deprecated" (#3685) 2020-01-28 20:38:50 +01:00
Luc
70a61f045f [now-cli] (Major) Use local .now scope for all commands and add scope to now whoami (#3643)
* use .now scope for commands

* add cache to getUser

* add cache on getTeams

* add cache for link

* refactor

* add error if NOW_ORG_ID is missing

* remove link cache

* refactor

* fix whoami

* add tests

* move fetching scope/org after subcommand condition

* Update packages/now-cli/src/util/projects/link.ts

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

* remove userId from global scope

* show team and user in whoami command

* reset whoami

* Revert "move fetching scope/org after subcommand condition"

This reverts commit d145e6164074fe2442178cd8fafbeb225c978b9c.

* remove `client` from main scope

* tests adjustments

* adjust tests

* adjust tests (bis)

Co-authored-by: Andy <AndyBitz@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-01-28 20:38:27 +01:00
luc
238a8a8593 Publish Canary
- now@17.0.0-canary.23
 - now-client@7.0.0-canary.3
2020-01-28 15:48:36 +01:00
Luc
6f2d5c0045 [now-cli] Add README.txt when linking project (#3681)
* add README.txt when linking project

* replace ` with "

* add test

* Apply suggestions from code review

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

* extract NOW_DIR_README.txt

* Update packages/now-cli/src/util/projects/NOW_DIR_README.txt

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

Co-authored-by: Nathan Rajlich <n@n8.io>
2020-01-28 15:47:45 +01:00
Luc
fc798da398 [now-client] Update @types/node-fetch (#3682)
* update @types/node-fetch

* fix type error (another)

* add noEmitOnError

* add build test github action to test

* Revert "fix type error (another)"

This reverts commit 1d0dace70a0bf2dfb2473a48408e560f060e5c50.

* Revert "add noEmitOnError"

This reverts commit 57286016c69723b625293621f7474882f802521d.

* Revert "update @types/node-fetch"

This reverts commit 6979b5f866faaa141e5be1b1bda353f01a41349c.

* Revert "Revert "update @types/node-fetch""

This reverts commit 7459fb768cd9574854ac0f9f3d48eca1e5e63821.

* Revert "Revert "fix type error (another)""

This reverts commit 820db234f82d0a624cddb625529196807b571b5e.

* Revert "Revert "add noEmitOnError""

This reverts commit 896fdb9f33c7f5d62fea409a073de5c614d11024.

* Revert "add build test github action to test"

This reverts commit a2f1c2f914e6c66653dfabad262311ee2a2720b3.

* add noEmitOnError to now-cli

* fix signal-exit in yarn.lock
2020-01-28 11:42:32 +01:00
luc
0804483316 Publish Canary
- now@17.0.0-canary.22
2020-01-28 11:36:50 +01:00
Luc
4a087f842e [now-cli] Use devCommand from project settings locally (#3673)
* pull devCommand from cloud

* filter out front end builders with devCommand

* remove unnecessary import

* fix wrong directory listing with devCommand

* fix server not stopping

* Apply suggestions from code review

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

* remove comment

* remove redundant "if"

Co-authored-by: Nathan Rajlich <n@n8.io>
2020-01-28 11:35:57 +01:00
luc
01c7bf0059 Publish Canary
- now@17.0.0-canary.21
2020-01-28 11:29:25 +01:00
Luc
6c439516db [now-cli] Add tip to connect git repositories after now login is successful (#3678)
* add tip after now login is successful

* write success message to stdout
2020-01-28 11:27:56 +01:00
Steven
0db4ee69ef [tests] Add timeout to test jobs (#3683)
Circle CI used to have a max timeout of 10 minutes.

This adds a timeout to each job so that hanging tests are noticed earlier.

For example, these have been "in progress" for 4 hours: 

![image](https://user-images.githubusercontent.com/229881/73222438-3a90ea00-4131-11ea-97a7-76651a2cce45.png)
2020-01-27 19:25:39 -05:00
Steven
aec8a7ac9a Publish Canary
- now@17.0.0-canary.20
 - now-client@7.0.0-canary.2
 - @now/routing-utils@1.5.2-canary.3
 - @now/ruby@1.0.2-canary.0
2020-01-27 17:08:32 -05:00
m5o
882bc8cb99 [now-ruby] Add rack examples to ruby integration tests (#3626)
* add rack examples to ruby integration tests
  * https://github.com/rack/rack

Co-authored-by: Steven <steven@ceriously.com>
2020-01-27 16:55:13 -05:00
Steven
9aad701dfd [now-routing-utils] Merge destination query string with path segments (#3679)
This PR changes the behavior so that `:segment` in the `source` is always added to the query string unless the `destination` query string already contains a key with the same name.
2020-01-27 16:24:10 -05:00
Luc
f224f574be [now-cli] Deprecate deploying files with Now CLI (#3650)
* deprecate uploading files instead of erroring

* fix misc bugs

* remove final `.`

* add test

* check .now folder does not exist in test

* clean up after test
2020-01-27 20:41:38 +01:00
Andy
e201eaa315 [frameworks] Extend CONTRIBUTING.md (#3675)
* [frameworks] Extend CONTRIBUTING.md

* Update .github/CONTRIBUTING.md

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

* Update .github/CONTRIBUTING.md

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

Co-authored-by: Steven <steven@ceriously.com>
2020-01-27 15:54:29 +01:00
Andy
b0ed1f2be0 [now-cli] Remove unused code (#3674)
* [now-cli] Remove unused code

* [now-cli] Remove more unused code
2020-01-27 15:19:41 +01:00
Steven
4ac33e1c03 [now-cli][now-client] Drop support for Node 8 (#3670)
Deployments no longer support Node 8 since reaching EOL so we can also drop all of the special casing used to support Node 8 in Now CLI and Now Client.

The `tsconfig.json` has been updated to ES2018 per [Node-Target-Mapping](https://github.com/microsoft/TypeScript/wiki/Node-Target-Mapping).
2020-01-27 13:32:07 +00:00
luc
27ca517666 Publish Canary
- @now/static-build@0.14.11-canary.1
2020-01-25 23:51:36 +01:00
Luc
734e9c072d [now-static-build] Add public folder to Gatsby cache (#3669)
* add `public` to gatsby cache

* add test
2020-01-25 23:38:36 +01:00
Forrest Oliphant
8db54f3093 [examples] Fix svelte example github link (#3657)
https://svelte.now-examples.now.sh/ currently points to https://github.com/zeit/now-examples/tree/master/svelte-functions ... this should be the right link.
2020-01-25 14:41:37 +00:00
Andy
886c0718d6 [tests] Fix GitHub Actions on master (#3664)
* Checkout master on master

* Check if checkout works

* Revert "Check if checkout works"

This reverts commit 66f712a43edfb938c551110c214661e4a920b492.

* Revert "Checkout master on master"

This reverts commit 41b6eab926474830629e758a51e7cfdd1947bdf2.

* Use --depth=10

* Add another fetch
2020-01-25 10:58:13 +01:00
Andy
e160a2f21f [tests] Use GitHub Actions for the tests (#3660)
* Initial Build step

* Typo

* Remove circleci config

* Fix command

* Change Node version

* Add unit tests

* Use artifact

* Fix workflow file

* Remove node_modules

* Remove .git

* Do not upload files

* Checkout master branch

* Use git fetch

* Add now-dev tests

* Fix workflow file

* Use node10 for building

* Use node12 for building

* Download Hugo before building

* Fetch master branch

* Do not cancel other jobs when one fails

* Add all tests

* Remove needs

* Add build step

* Move test up

* Use isCanary function and remove tests

* Update Publish workflow

* Update .github/workflows/continuous-integration.yml

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

* Specify more events

* Add publish.sh script

* Remove Node8

Co-authored-by: Steven <steven@ceriously.com>
2020-01-25 00:42:55 +01:00
JJ Kasper
e09a418423 Publish Stable
- @now/next@2.3.12
2020-01-24 12:33:56 -06:00
JJ Kasper
52d4464368 Publish Canary
- @now/next@2.3.12-canary.0
2020-01-24 12:31:50 -06:00
JJ Kasper
4dc635e5f2 [now-next] Revert handle: miss/hit (#3658)
This reverts `handle: miss/hit` as it still needs some things sorted out before we're ready to use it in `@now/next`
2020-01-24 18:22:25 +00:00
Steven
510fb7ee7e Publish Canary
- @now/build-utils@1.3.7-canary.1
 - now@17.0.0-canary.19
2020-01-24 12:16:13 -05:00
Steven
243451e94b [now-build-utils] Add function detectApiExtensions() (#3653)
* [now-routing-utils] Add function detectApiExtensions

* Add more tests, fix broken test

* Add missing check for extensions

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-01-24 12:07:29 -05:00
Andy Bitz
11bbda977d Publish Stable
- @now/frameworks@0.0.7
 - @now/next@2.3.11
2020-01-24 17:20:55 +01:00
Andy Bitz
62c050f394 Publish Canary
- now@17.0.0-canary.18
 - now-client@7.0.0-canary.1
2020-01-24 17:19:27 +01:00
Andy
bd5a013312 [now-client] (Major) Remove builds check from now-client and change events (#3648)
* [now-client][now-cli] Remove builds check from now-client

* [now-client] Adjust README and change version

* Change events and adjust build error

* Use message from error

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

Co-Authored-By: Luc <luc.leray@gmail.com>

* [now-cli] Rename event

* Make types more consistent

* Fix type in process-legacy-deployment

* Adjust type in test

* Update type

* Make events type simpler

Co-authored-by: Max <8418866+rdev@users.noreply.github.com>
Co-authored-by: Luc <luc.leray@gmail.com>
2020-01-24 17:18:56 +01:00
Andy Bitz
1823cf452e Publish Canary
- @now/next@2.3.11-canary.4
2020-01-24 16:09:18 +01:00
Andy
c426d72ccf [now-next] Include file mode for pseudo layers (#3655) 2020-01-24 16:08:39 +01:00
Alex Grover
ddf59c052d Remove duplicated line from .gitignore (#3651) 2020-01-24 11:03:51 +01:00
luc
1dcf6e7fb1 Publish Canary
- now@17.0.0-canary.17
2020-01-23 20:06:18 +01:00
Luc
d4f4792988 [now-cli] Add --confirm to help (#3625)
```
$ now --help
[...]
  -c, --confirm                  Confirm default options and skip questions
```
2020-01-23 19:00:55 +00:00
Steven
7e1f2bd10e Publish Canary
- @now/build-utils@1.3.7-canary.0
2020-01-23 12:29:22 -05:00
Steven
a80a1d0c1d [now-build-utils] Fix api directory detection (#3647)
There was an issue where `@now/next` was emitting an api directory with serverless functions but the functions should not be renamed.
2020-01-23 16:54:34 +00:00
Steven
8ff747b4d7 Publish Canary
- @now/next@2.3.11-canary.3
 - @now/routing-utils@1.5.2-canary.2
2020-01-23 09:37:30 -05:00
Steven
aa63b5a581 [github] Update codeowners (#3642)
Added a few more code owners
2020-01-23 00:25:25 +00:00
luc
2094ec3c99 Publish Canary
- now@17.0.0-canary.16
2020-01-23 00:57:56 +01:00
Luc
bf30d10211 [now-cli] Output error if NOW_PROJECT_ID/NOW_ORG_ID is defined without the other (#3630)
* output error if one of both env is missing

* add test

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-01-23 00:53:15 +01:00
Luc
ccc03c9c6e [now-cli] Add warning if linked project was deleted or access was removed (#3631)
![image](https://user-images.githubusercontent.com/6616955/72800302-4ff4a880-3c47-11ea-8d74-0ae0c18469da.png)
2020-01-22 23:27:30 +00:00
Steven
4b7367e2dc [now-routing-utils] Fix segments in query string (#3640)
This PR a regression when path segments are used in the query string.

Take a look at the following ASCII Table for why I had to delete certain parts of the parsed url before formatting again.

https://nodejs.org/api/url.html#url_url_strings_and_url_objects

Related to #3539
2020-01-22 22:46:47 +00:00
JJ Kasper
00aa56a095 [now-next] Add headers support for custom-routes (#3494)
This adds support for `headers` in custom-routes which was landed in Next.js. 

This also updates `@now/routing-utils` `convertHeaders` to call `sourceToRegex` to match behavior with Next.js and allow using `segments` to match in the header `source` as not being able to use the same syntax for a header `source` as a `redirect` source could get confusing
2020-01-22 20:45:36 +00:00
Steven
56ae93a2a5 [examples] Fix jekyll readme build command (#3639)
Fixes #3634
2020-01-22 18:19:12 +00:00
JJ Kasper
adb32a09d3 Publish Canary
- @now/next@2.3.11-canary.2
 - @now/routing-utils@1.5.2-canary.1
2020-01-22 11:46:57 -06:00
JJ Kasper
3358d8e44c [now-next] Add handle: miss and handle: hit for custom-routes (#3489)
This is required to match custom-routes behavior in Next.js by checking dynamic routes after each rewrite although is currently blocked on `now dev` also supporting the feature

This reverts commit 0da98a7f5d.
2020-01-22 17:39:27 +00:00
Steven
c3bd2698e8 [now-routing-utils] Disallow "status" in hit phase (#3637)
This will prevent any strange behavior since production already ignores status code in the hit phase.
2020-01-22 17:03:10 +00:00
Steven
a7baa4761d Publish Canary
- now@17.0.0-canary.15
2020-01-21 19:56:55 -05:00
Steven
5dd2daa970 [now dev] Add support for handle: miss and handle: hit (#3537)
- [x] Add tests from now-proxy for `handle: miss`
- [x] Add tests from now-proxy for `handle: hit`
- [x] Add file output renaming when `featHandleMiss` is true (also assign true for now dev)
2020-01-22 00:54:24 +00:00
JJ Kasper
dd36a489ed Publish Canary
- @now/frameworks@0.0.7-canary.0
 - @now/next@2.3.11-canary.1
 - @now/static-build@0.14.11-canary.0
2020-01-20 15:36:58 -06:00
JJ Kasper
2e742209e3 [now-next] Add initial support for static 404 (#3628)
This adds initial support for static 404 pages when enabled for Next.js applications > `9.2.1-canary.3` it also disables tracing/logging related to lambdas when there aren't any lambdas besides the `_error` when a static 404 is being used 

Closes: #3368
2020-01-20 20:55:08 +00:00
Andy
8d13464cba [frameworks][now-static-build] Use hugo -D --gc as build command (#3624)
* [frameworks][now-static-build] Use `hugo --gc` as build command

* Add -D option
2020-01-20 19:46:15 +01:00
Max Rovensky
20fdcfa0af Publish Stable
- @now/static-build@0.14.10
2020-01-18 04:00:08 +08:00
Max
fac004f83c [now-static-build] Remove legacy message from static build (#3618)
* Remove legacy message from static build

* Remove unused config

* Remove unused config
2020-01-17 20:59:10 +01:00
Andy Bitz
5fee4bbad1 Publish Stable
- @now/static-build@0.14.9
2020-01-17 20:21:52 +01:00
Andy
18e4b18839 [now-static-build] Ignore commands for non-zero-config (#3617) 2020-01-17 20:19:53 +01:00
Max Rovensky
b8627fd384 Publish Stable
- @now/static-build@0.14.8
2020-01-18 02:42:30 +08:00
Max
4e2db6f8a5 [now-static-build] Improve static build errors copy (#3616)
* Improve static build errors copy

* Update packages/now-static-build/src/index.ts

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

* Update packages/now-static-build/src/index.ts

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

Co-authored-by: Leo Lamprecht <mindrun@icloud.com>
2020-01-17 19:36:52 +01:00
Steven
b685a3afdd Publish Canary
- @now/next@2.3.11-canary.0
 - @now/node@1.3.6-canary.0
2020-01-17 13:09:32 -05:00
Steven
aea3f58970 [api] Fix build script (#3615)
I was getting errors when running `yarn build` locally because the public directory already exists.

This will make sure the public directory is deleted before generating it again.
2020-01-17 13:08:41 -05:00
Steven
b0bb90dc11 Bump node-file-trace to 0.5.1 (#3613)
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
2020-01-17 13:07:59 -05:00
345 changed files with 8142 additions and 3767 deletions

View File

@@ -1,501 +0,0 @@
version: 2
jobs:
install:
docker:
- image: circleci/node:10
working_directory: ~/repo
environment:
GOPATH: $HOME/go
steps:
- checkout
- restore_cache:
keys:
- 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
- run:
name: Installing the latest version of Go
command: sudo apt-get install golang-go
- run:
name: Installing Dependencies
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
- packages/now-client/node_modules
- packages/now-go/node_modules
- packages/now-next/node_modules
- packages/now-node/node_modules
- packages/now-node-bridge/node_modules
- packages/now-python/node_modules
- packages/now-routing-utils/node_modules
- packages/now-ruby/node_modules
- packages/now-static-build/node_modules
key: v1-dependencies-{{ checksum "yarn.lock" }}
- persist_to_workspace:
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
- packages/now-client/node_modules
- packages/now-go/node_modules
- packages/now-next/node_modules
- packages/now-node/node_modules
- packages/now-node-bridge/node_modules
- packages/now-python/node_modules
- packages/now-routing-utils/node_modules
- packages/now-ruby/node_modules
- packages/now-static-build/node_modules
build:
docker:
- image: circleci/node:10
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Linking dependencies
command: yarn bootstrap
- run:
name: Building
command: yarn build
- store_artifacts:
path: packages/now-cli/dist
- persist_to_workspace:
root: .
paths:
- packages/gatsby-plugin-now/test/fixtures
- packages/now-build-utils/dist
- packages/now-cgi/dist
- packages/now-cli/dist
- packages/now-cli/assets
- packages/now-client/dist
- packages/now-go/dist
- packages/now-next/dist
- packages/now-node/dist
- packages/now-node/test/fixtures/15-helpers/ts/types.d.ts
- packages/now-node/test/fixtures/11-symlinks/symlink
- packages/now-node-bridge/index.js
- packages/now-node-bridge/bridge.js
- packages/now-python/dist
- 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:
- 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: Linting Code
command: yarn test-lint
test-integration-macos-node-8:
macos:
xcode: '9.0.1'
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Output version
command: node --version
- run:
name: Running Integration Tests
command: yarn test-integration --clean false
test-integration-macos-node-10:
macos:
xcode: '10.0.0'
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Output version
command: node --version
- run:
name: Running Integration Tests
command: yarn test-integration --clean false
test-integration-macos-node-12:
macos:
xcode: '10.3.0'
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Output version
command: node --version
- run:
name: Running Integration Tests
command: yarn test-integration --clean false
test-integration-linux-node-8:
docker:
- image: circleci/node:8
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Output version
command: node --version
- run:
name: Running Integration Tests
command: yarn test-integration --clean false
test-integration-linux-node-10:
docker:
- image: circleci/node:10
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Output version
command: node --version
- run:
name: Running Integration Tests
command: yarn test-integration --clean false
test-integration-linux-node-12:
docker:
- image: circleci/node:12
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Output version
command: node --version
- run:
name: Running Integration Tests
command: yarn test-integration --clean false
test-integration-macos-now-dev-node-8:
macos:
xcode: '9.0.1'
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Output version
command: node --version
- run:
name: Downloading Hugo
command: curl -L -O https://github.com/gohugoio/hugo/releases/download/v0.56.0/hugo_0.56.0_macOS-64bit.tar.gz && tar -xzf hugo_0.56.0_macOS-64bit.tar.gz && mv ./hugo packages/now-cli/test/dev/fixtures/08-hugo/
- run:
name: Running Integration Tests for `now dev`
command: yarn test-integration-now-dev --clean false
test-integration-macos-now-dev-node-10:
macos:
xcode: '10.0.0'
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Output version
command: node --version
- run:
name: Downloading Hugo
command: curl -L -O https://github.com/gohugoio/hugo/releases/download/v0.56.0/hugo_0.56.0_macOS-64bit.tar.gz && tar -xzf hugo_0.56.0_macOS-64bit.tar.gz && mv ./hugo packages/now-cli/test/dev/fixtures/08-hugo/
- run:
name: Running Integration Tests for `now dev`
command: yarn test-integration-now-dev --clean false
test-integration-macos-now-dev-node-12:
macos:
xcode: '10.3.0'
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Output version
command: node --version
- run:
name: Downloading Hugo
command: curl -L -O https://github.com/gohugoio/hugo/releases/download/v0.56.0/hugo_0.56.0_macOS-64bit.tar.gz && tar -xzf hugo_0.56.0_macOS-64bit.tar.gz && mv ./hugo packages/now-cli/test/dev/fixtures/08-hugo/
- run:
name: Running Integration Tests for `now dev`
command: yarn test-integration-now-dev --clean false
test-integration-linux-now-dev-node-8:
docker:
- image: circleci/node:8
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Output version
command: node --version
- run:
name: Downloading Hugo
command: curl -L -O https://github.com/gohugoio/hugo/releases/download/v0.55.6/hugo_0.55.6_Linux-64bit.tar.gz && tar -xzf hugo_0.55.6_Linux-64bit.tar.gz && mv ./hugo packages/now-cli/test/dev/fixtures/08-hugo/
- run:
name: Running Integration Tests for `now dev`
command: yarn test-integration-now-dev --clean false
test-integration-linux-now-dev-node-10:
docker:
- image: circleci/node:10
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Output version
command: node --version
- run:
name: Downloading Hugo
command: curl -L -O https://github.com/gohugoio/hugo/releases/download/v0.55.6/hugo_0.55.6_Linux-64bit.tar.gz && tar -xzf hugo_0.55.6_Linux-64bit.tar.gz && mv ./hugo packages/now-cli/test/dev/fixtures/08-hugo/
- run:
name: Running Integration Tests for `now dev`
command: yarn test-integration-now-dev --clean false
test-integration-linux-now-dev-node-12:
docker:
- image: circleci/node:12
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Output version
command: node --version
- run:
name: Downloading Hugo
command: curl -L -O https://github.com/gohugoio/hugo/releases/download/v0.55.6/hugo_0.55.6_Linux-64bit.tar.gz && tar -xzf hugo_0.55.6_Linux-64bit.tar.gz && mv ./hugo packages/now-cli/test/dev/fixtures/08-hugo/
- run:
name: Running Integration Tests for `now dev`
command: yarn test-integration-now-dev --clean false
test-integration-once:
docker:
- image: circleci/node:10
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Output version
command: node --version
- run:
name: Running Integration Tests Once
command: yarn test-integration-once --clean false
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: 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
source-maps:
docker:
- image: circleci/node:10
working_directory: ~/repo
steps:
- checkout
- attach_workspace:
at: .
- run:
name: Installing Sentry CLI
command: npm install -g @sentry/cli
- run:
name: Creating a New Sentry Release
command: sentry-cli releases new now-cli@`git describe --tags`
- run:
name: Upload Sourcemap Files
command: sentry-cli releases files now-cli@`git describe --tags` upload-sourcemaps ./dist
- run:
name: Finalize Sentry Release
command: sentry-cli releases finalize now-cli@`git describe --tags`
workflows:
version: 2
unscheduled:
jobs:
- install:
filters:
tags:
only: /.*/
- build:
requires:
- install
filters:
tags:
only: /.*/
- test-lint:
requires:
- build
filters:
tags:
only: /.*/
- test-integration-macos-node-8:
requires:
- build
filters:
tags:
only: /.*/
- test-integration-macos-node-10:
requires:
- build
filters:
tags:
only: /.*/
- test-integration-macos-node-12:
requires:
- build
filters:
tags:
only: /.*/
- test-integration-linux-node-8:
requires:
- build
filters:
tags:
only: /.*/
- test-integration-linux-node-10:
requires:
- build
filters:
tags:
only: /.*/
- test-integration-linux-node-12:
requires:
- build
filters:
tags:
only: /.*/
- test-integration-macos-now-dev-node-8:
requires:
- build
filters:
tags:
only: /.*/
- test-integration-macos-now-dev-node-10:
requires:
- build
filters:
tags:
only: /.*/
- test-integration-macos-now-dev-node-12:
requires:
- build
filters:
tags:
only: /.*/
- test-integration-linux-now-dev-node-8:
requires:
- build
filters:
tags:
only: /.*/
- test-integration-linux-now-dev-node-10:
requires:
- build
filters:
tags:
only: /.*/
- test-integration-linux-now-dev-node-12:
requires:
- build
filters:
tags:
only: /.*/
- test-integration-once:
requires:
- build
- test-unit:
requires:
- build
filters:
tags:
only: /.*/
- coverage:
requires:
- test-integration-macos-node-8
- test-integration-macos-node-10
- test-integration-macos-node-12
- test-integration-linux-node-8
- test-integration-linux-node-10
- test-integration-linux-node-12
- test-integration-macos-now-dev-node-8
- test-integration-macos-now-dev-node-10
- test-integration-macos-now-dev-node-12
- test-integration-linux-now-dev-node-8
- test-integration-linux-now-dev-node-10
- test-integration-linux-now-dev-node-12
- test-integration-once
- test-unit
- test-lint
filters:
tags:
only: /.*/

4
.gitattributes vendored
View File

@@ -1,3 +1,7 @@
# Ignore test fixtures in GitHub Languages
# See https://github.com/github/linguist#vendored-code
packages/*/test/* linguist-vendored
# Go build fails with Windows line endings.
*.go text eol=lf
go.mod text eol=lf

9
.github/CODEOWNERS vendored
View File

@@ -2,6 +2,8 @@
# https://help.github.com/en/articles/about-code-owners
* @tootallnate @leo
/.github/workflows @AndyBitz @styfle
/packages/frameworks @AndyBitz
/packages/now-cli/src/commands/dev/ @tootallnate @leo @styfle @AndyBitz
/packages/now-cli/src/util/dev/ @tootallnate @leo @styfle @AndyBitz
/packages/now-cli/src/commands/domains/ @javivelasco @mglagola @anatrajkovska
@@ -10,13 +12,16 @@
/packages/now-build-utils @styfle @AndyBitz
/packages/now-node @styfle @tootallnate @lucleray
/packages/now-node-bridge @styfle @tootallnate @lucleray
/packages/now-next @Timer
/packages/now-next @Timer @ijjk
/packages/now-go @styfle @sophearak
/packages/now-python @styfle @sophearak
/packages/now-ruby @styfle @coetry @nathancahill
/packages/now-static-build @styfle @AndyBitz
/packages/now-routing-utils @dav-is
/packages/now-routing-utils @styfle @dav-is @ijjk
/examples @msweeneydev @timothyis
/examples/create-react-app @Timer
/examples/nextjs @timneutkens
/examples/hugo @msweeneydev @timothyis @styfle
/examples/jekyll @msweeneydev @timothyis @sarupbanskota
/examples/zola @msweeneydev @timothyis @styfle

View File

@@ -97,10 +97,9 @@ Sometimes you want to test changes to a Builder against an existing project, may
## Add a New Framework
1. Add the framework to the `@now/frameworks` package.
The file is located in `packages/frameworks/frameworks.json`.
2. Add an example to the `examples/` directory.
The name of the directory should equal the slug of the framework in `@now/frameworks`.
The `.github/EXAMPLE_README_TEMPLATE.md` file can be used to create a README for the example.
3. Finally, `@now/static-build` must be adjusted.
The files `packages/now-static-build/src/frameworks.ts` has to be extended.
You can add support for a new Framework by creating a Pull Request for this repository and following the steps below:
1. Add the Framework to the `@now/frameworks` package: The file is located in `packages/frameworks/frameworks.json`. You can copy the structure of an existing one and adjust the required fields. Note that the `settings` property either contains a `value` or a `placeholder`. The `value` property is used when something is not configurable, the `placeholder` is used when something is configurable and can be changed with configuration. An example would be the Output Directory for Hugo, it's `public` by default but can be changed through its config file, so we use `placeholder` with an explanation of what can be used.
2. Add an example to the `examples/` directory: The name of the directory should equal the slug of the framework used in `@now/frameworks`. The `.github/EXAMPLE_README_TEMPLATE.md` file can be used to create a `README.md` file for the example.
3. Update the `@now/static-build` package: The file `packages/now-static-build/src/frameworks.ts` has to be extended. You can add default routes that will always be applied to projects that use this Framework or specify some paths that will be cached to speed up the build process.
4. After your Pull Request has been merged and released, other users can select the example on the ZEIT Now dashboard and deploy it.

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Name](site-link) site that can be deploy
Deploy your own [Name] project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now-examples/tree/master/example-directory)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now-examples/tree/master/example-directory)
### How We Created This Example

18
.github/workflows/cancel.yml vendored Normal file
View File

@@ -0,0 +1,18 @@
name: Cancel
on:
push:
branches:
- '*'
- '!master'
jobs:
cancel:
name: 'Cancel Previous Runs'
runs-on: ubuntu-latest
timeout-minutes: 3
steps:
- uses: styfle/cancel-workflow-action@0.2.0
with:
workflow_id: 435869
access_token: ${{ secrets.GITHUB_WORKFLOW_TOKEN }}

View File

@@ -0,0 +1,109 @@
name: CI
on:
push:
branches:
- master
tags:
- '!*'
pull_request:
jobs:
test-unit:
name: Unit Tests
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
node: [10, 12]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- run: git fetch origin master --depth=10
- run: git fetch origin ${{ github.ref }} --depth=10
- uses: actions/setup-node@v1
- run: yarn install
- run: yarn run build
- run: yarn run test-lint
- run: yarn run test-unit --clean false
- name: Upload Artifact
if: matrix.os == 'ubuntu-latest' && matrix.node == 12 # only run once
uses: actions/upload-artifact@v1
with:
name: test-unit-output
path: packages/now-cli/.nyc_output
test-integration:
name: Integration Tests
timeout-minutes: 120
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: git fetch origin master --depth=10
- run: git fetch origin ${{ github.ref }} --depth=10
- run: yarn install
- run: yarn run build
- run: yarn test-integration-once --clean false
test-now-cli:
name: Now CLI Tests
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
node: [10, 12]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- run: git fetch origin master --depth=10
- run: git fetch origin ${{ github.ref }} --depth=10
- name: Install Hugo
if: matrix.os == 'macos-latest'
run: curl -L -O https://github.com/gohugoio/hugo/releases/download/v0.56.0/hugo_0.56.0_macOS-64bit.tar.gz && tar -xzf hugo_0.56.0_macOS-64bit.tar.gz && mv ./hugo packages/now-cli/test/dev/fixtures/08-hugo/
- run: yarn install
- run: yarn run build
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: yarn test-integration --clean false
test-now-dev:
name: "`now dev` Tests"
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
node: [10, 12]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
- run: git fetch origin master --depth=10
- run: git fetch origin ${{ github.ref }} --depth=10
- name: Install Hugo
if: matrix.os == 'macos-latest'
run: curl -L -O https://github.com/gohugoio/hugo/releases/download/v0.56.0/hugo_0.56.0_macOS-64bit.tar.gz && tar -xzf hugo_0.56.0_macOS-64bit.tar.gz && mv ./hugo packages/now-cli/test/dev/fixtures/08-hugo/
- run: yarn install
- run: yarn run build
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node }}
- run: yarn test-integration-now-dev --clean false
coverage:
name: Coverage
timeout-minutes: 10
needs: [test-unit, test-now-cli, test-now-dev, test-integration]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- run: git fetch origin master --depth=10
- run: git fetch origin ${{ github.ref }} --depth=10
- uses: actions/download-artifact@v1
with:
name: test-unit-output
path: packages/now-cli/.nyc_output
- run: yarn install
- run: yarn workspace now run coverage

View File

@@ -4,25 +4,18 @@ on:
push:
branches:
- master
- canary
tags:
- '!*'
jobs:
Publish:
publish:
name: Publish
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [10.x]
steps:
- uses: actions/checkout@v1
- name: Checkout
uses: actions/setup-node@v1
- uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
node-version: 10
- name: Install
run: yarn install --check-files --frozen-lockfile
- name: Build

View File

@@ -1,6 +1,6 @@
![now](https://assets.zeit.co/image/upload/v1542240976/repositories/now-cli/now-cli-repo-banner-v3.png)
![now](https://assets.zeit.co/image/upload/v1581518533/repositories/now-cli/v4.png)
[![Build Status](https://badgen.net/circleci/github/zeit/now/master)](https://circleci.com/gh/zeit/workflows/now/tree/master)
[![CI Status](https://badgen.net/github/checks/zeit/now?label=CI)](https://github.com/zeit/now/actions?workflow=CI)
[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/zeit)
## Usage
@@ -16,13 +16,12 @@ To quickly start a new project, run the following commands:
```
now init # Pick an example project to clone
cd <PROJECT> # Change directory to the newly created project
now dev # Run locally during development
now # Deploy to the cloud
```
## Documentation
For details on how to use Now CLI, check out our [documentation](https://zeit.co/docs).
For details on how to use Now CLI, check out our [documentation](https://zeit.co/docs/now-cli).
## Caught a Bug?

View File

@@ -2,17 +2,19 @@ import { NowRequest, NowResponse } from '@now/node';
import { withApiHandler } from './_lib/util/with-api-handler';
import frameworkList, { Framework } from '../packages/frameworks';
const frameworks: Framework[] = (frameworkList as Framework[]).map(
framework => {
delete framework.detectors;
const frameworks = (frameworkList as Framework[]).map(frameworkItem => {
const framework = {
...frameworkItem,
hasDetectors: Boolean(frameworkItem.detectors),
detectors: undefined,
};
if (framework.logo) {
framework.logo = `https://res.cloudinary.com/zeit-inc/image/fetch/${framework.logo}`;
}
return framework;
if (framework.logo) {
framework.logo = `https://res.cloudinary.com/zeit-inc/image/fetch/${framework.logo}`;
}
);
return framework;
});
export default withApiHandler(async function(
req: NowRequest,

View File

@@ -6,7 +6,7 @@ This directory is a brief example of an [AMP](https://amp.dev/) site that can be
Deploy your own AMP project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/amp)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/amp)
_Live Example: https://amp.now-examples.now.sh_

View File

@@ -1,4 +1,4 @@
![Angular Logo](../../packages/frameworks/logos/angular.svg)
![Angular Logo](https://github.com/zeit/now/blob/master/packages/frameworks/logos/angular.svg)
# Angular Example
@@ -8,7 +8,7 @@ This directory is a brief example of an [Angular](https://angular.io/) app that
Deploy your own Angular project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/angular)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/angular)
_Live Example: https://angular.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Assemble](http://assemble.io/) app that
Deploy your own Assemble project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/assemble)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/assemble)
_Live Example: https://assemble.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of an [Aurelia](https://aurelia.io/) app that
Deploy your own Aurelia project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/aurelia)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/aurelia)
_Live Example: https://aurelia.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Brunch](https://brunch.io/) site that ca
Deploy your own Brunch project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/brunch)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/brunch)
_Live Example: https://brunch.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Charge.js](https://charge.js.org/) site
Deploy your own Charge.js project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/charge)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/charge)
_Live Example: https://charge.now-examples.now.sh_

View File

@@ -1,4 +1,4 @@
![React Logo](../../packages/frameworks/logos/react.svg)
![React Logo](https://github.com/zeit/now/blob/master/packages/frameworks/logos/react.svg)
# React Example
@@ -8,7 +8,7 @@ This directory is a brief example of a [React](https://reactjs.org/) app with [S
Deploy your own React project, along with Serverless Functions, with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/create-react-app-functions)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/create-react-app-functions)
_Live Example: https://create-react-app.now-examples.now.sh/_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of using a Custom Build script that can be dep
Deploy your own Custom Built project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/custom-build)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/custom-build)
_Live Example: https://custom-build.now-examples.now.sh_

View File

@@ -1,4 +1,4 @@
![Docusaurus Logo](../../packages/frameworks/logos/docusaurus.svg)
![Docusaurus Logo](https://github.com/zeit/now/blob/master/packages/frameworks/logos/docusaurus.svg)
# Docusaurus Example
@@ -8,7 +8,7 @@ This directory is a brief example of a [Docusaurus](https://docusaurus.io/) site
Deploy your own Docusaurus project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/docusaurus)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/docusaurus)
_Live Example: https://docusaurus.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Docz](https://www.docz.site/) site that
Deploy your own Docz project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/docz)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/docz)
_Live Example: https://docz.now-examples.now.sh_

View File

@@ -1,4 +1,4 @@
![Eleventy Logo](../../packages/frameworks/logos/eleventy.svg)
![Eleventy Logo](https://github.com/zeit/now/blob/master/packages/frameworks/logos/eleventy.svg)
# Eleventy Example
@@ -8,7 +8,7 @@ This directory is a brief example of a [Eleventy](https://www.11ty.io/) site tha
Deploy your own Eleventy project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/eleventy)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/eleventy)
_Live Example: https://eleventy.now-examples.now.sh_

View File

@@ -1,4 +1,4 @@
![Ember Logo](../../packages/frameworks/logos/ember.svg)
![Ember Logo](https://github.com/zeit/now/blob/master/packages/frameworks/logos/ember.svg)
# Ember Example
@@ -8,7 +8,7 @@ This directory is a brief example of an [Ember](https://emberjs.com/) app that c
Deploy your own Ember project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/ember)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/ember)
_Live Example: https://ember.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Foundation](https://foundation.zurb.com/
Deploy your own Foundation project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/foundation)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/foundation)
_Live Example: https://foundation.now-examples.now.sh_

View File

@@ -1,4 +1,4 @@
![Gatsby Logo](../../packages/frameworks/logos/gatsby.svg)
![Gatsby Logo](https://github.com/zeit/now/blob/master/packages/frameworks/logos/gatsby.svg)
# Gatsby Example
@@ -8,7 +8,7 @@ This directory is a brief example of a [Gatsby](https://www.gatsbyjs.org/) app w
Deploy your own Gatsby project, along with Serverless Functions, with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/gatsby)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/gatsby)
_Live Example: https://gatsby.now-examples.now.sh_

View File

@@ -1,4 +1,4 @@
![Gridsome Logo](../../packages/frameworks/logos/gridsome.svg)
![Gridsome Logo](https://github.com/zeit/now/blob/master/packages/frameworks/logos/gridsome.svg)
# Gridsome Example
@@ -8,7 +8,7 @@ This directory is a brief example of a [Gridsome](https://gridsome.org/) app tha
Deploy your own Gridsome project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/gridsome)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/gridsome)
_Live Example: https://gridsome.now-examples.now.sh_

View File

@@ -1,4 +1,4 @@
![Hexo Logo](../../packages/frameworks/logos/hexo.svg)
![Hexo Logo](https://github.com/zeit/now/blob/master/packages/frameworks/logos/hexo.svg)
# Hexo Example
@@ -8,7 +8,7 @@ This directory is a brief example of a [Hexo](https://hexo.io/) site that can be
Deploy your own Hexo project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/hexo)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/hexo)
_Live Example: https://hexo.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Hugo](https://gohugo.io/) app that can b
Deploy your own Hugo project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/hugo)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/hugo)
_Live Example: https://hugo.now-examples.now.sh_

View File

@@ -28,3 +28,5 @@ npm-debug.log
/junit.xml
partials/structure/stylesheet.html
!dist

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1 @@
!function(n){function t(e){if(r[e])return r[e].exports;var o=r[e]={i:e,l:!1,exports:{}};return n[e].call(o.exports,o,o.exports,t),o.l=!0,o.exports}var r={};t.m=n,t.c=r,t.i=function(n){return n},t.d=function(n,r,e){t.o(n,r)||Object.defineProperty(n,r,{configurable:!1,enumerable:!0,get:e})},t.n=function(n){var r=n&&n.__esModule?function(){return n.default}:function(){return n};return t.d(r,"a",r),r},t.o=function(n,t){return Object.prototype.hasOwnProperty.call(n,t)},t.p="",t(t.s=1)}([function(n,t){},function(n,t,r){"use strict";var e=r(0);!function(n){n&&n.__esModule}(e)}]);

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [HyperApp](https://github.com/jorgebucara
Deploy your own HyperApp project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/hyperapp)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/hyperapp)
_Live Example: https://hyperapp.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of an [Ionic React](https://ionicframework.com
Deploy your own Ionic React project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/ionic-react)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/ionic-react)
_Live Example: https://ionic-react.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Jekyll](https://jekyllrb.com/) site that
Deploy your own Jekyll project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/jekyll)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/jekyll)
_Live Example: https://jekyll.now-examples.now.sh_
@@ -25,18 +25,3 @@ You can deploy your new Jekyll project with a single command from your terminal
```shell
$ now
```
### Example Changes
This example adds a `package.json` file with the following:
```json
{
"private": true,
"scripts": {
"build": "jekyll build && mv _site public"
}
}
```
This instructs ZEIT Now to build the Jekyll website and move the output to the public directory.

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Marko.js](https://markojs.com/) app that
Deploy your own Marko.js project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/marko)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/marko)
_Live Example: https://marko.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [mdx-deck](https://github.com/jxnblk/mdx-
Deploy your own mdx-deck project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/mdx-deck)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/mdx-deck)
_Live Example: https://mdx-deck.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Metalsmith](https://metalsmith.io/) app
Deploy your own Metalsmith project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/metalsmith)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/metalsmith)
_Live Example: https://metalsmith.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Middleman](https://middlemanapp.com/) si
Deploy your own Middleman project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/middleman)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/middleman)
_Live Example: https://middleman.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Mithril](https://mithril.js.org/) app th
Deploy your own Mithril project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/mithril)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/mithril)
_Live Example: https://mithril.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [MkDocs](https://www.mkdocs.org/) site th
Deploy your own MkDocs project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/mkdocs)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/mkdocs)
_Live Example: https://mkdocs.now-examples.now.sh_

View File

@@ -13,7 +13,6 @@
# misc
.DS_Store
.env
npm-debug.log*
yarn-debug.log*
yarn-error.log*

View File

@@ -1,4 +1,4 @@
![Next.js Logo](../../packages/frameworks/logos/next.svg)
![Next.js Logo](https://github.com/zeit/now/blob/master/packages/frameworks/logos/next.svg)
# Next.js Example
@@ -8,7 +8,7 @@ This directory is a brief example of a [Next.js](https://nextjs.org) app that ca
Deploy your own Next.js project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/nextjs)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/nextjs)
_Live Example: https://nextjs.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Nuxt.js](https://nuxtjs.org) app that ca
Deploy your own Nuxt.js project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/nuxtjs)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/nuxtjs)
_Live Example: https://nuxtjs.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Pelican](https://docs.getpelican.com/en/
Deploy your own Pelican project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/pelican)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/pelican)
_Live Example: https://pelican.now-examples.now.sh_

View File

@@ -1,4 +1,4 @@
![Polymer Logo](../../packages/frameworks/logos/polymer.svg)
![Polymer Logo](https://github.com/zeit/now/blob/master/packages/frameworks/logos/polymer.svg)
# Polymer Example
@@ -8,7 +8,7 @@ This directory is a brief example of a [Polymer](https://www.polymer-project.org
Deploy your own Polymer project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/polymer)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/polymer)
_Live Example: https://polymer.now-examples.now.sh_

View File

@@ -1,4 +1,4 @@
![Preact Logo](../../packages/frameworks/logos/preact.svg)
![Preact Logo](https://github.com/zeit/now/blob/master/packages/frameworks/logos/preact.svg)
# Preact Example
@@ -8,7 +8,7 @@ This directory is a brief example of a [Preact](https://preactjs.com/) app that
Deploy your own Preact project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/preact)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/preact)
_Live Example: https://preact.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Riot.js](https://riot.js.org/) app that
Deploy your own Riot.js project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/riot)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/riot)
_Live Example: https://riot.now-examples.now.sh_

View File

@@ -1,4 +1,4 @@
![Saber Logo](../../packages/frameworks/logos/saber.svg)
![Saber Logo](https://github.com/zeit/now/blob/master/packages/frameworks/logos/saber.svg)
# Saber Example
@@ -8,7 +8,7 @@ This directory is a brief example of a [Saber](https://saber.land) site that can
Deploy your own Saber project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/saber)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/saber)
_Live Example: https://saber.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Sapper](https://sapper.svelte.dev/) app
Deploy your own Sapper project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/sapper)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/sapper)
_Live Example: https://sapper.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Stencil](https://stenciljs.com/) app tha
Deploy your own Stencil project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/stencil)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/stencil)
_Live Example: https://stencil.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Storybook](https://storybook.js.org/) ap
Deploy your own Storybook project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/storybook)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/storybook)
_Live Example: https://storybook.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Svelte](https://svelte.dev/) app with [S
Deploy your own Svelte project, along with Serverless Functions, with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/svelte)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/svelte)
_Live Example: https://svelte.now-examples.now.sh_

View File

@@ -20,7 +20,7 @@
</h2>
<p>
<a
href="https://github.com/zeit/now/tree/master/examples/svelte-functions"
href="https://github.com/zeit/now/tree/master/examples/svelte"
target="_blank"
rel="noreferrer noopener">
This project

View File

@@ -1,4 +1,4 @@
![UmiJS Logo](../../packages/frameworks/logos/umi.svg)
![UmiJS Logo](https://github.com/zeit/now/blob/master/packages/frameworks/logos/umi.svg)
# UmiJS Example
@@ -8,7 +8,7 @@ This directory is a brief example of a [UmiJS](https://umijs.org/) app that can
Deploy your own UmiJS project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/umijs)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/umijs)
_Live Example: https://umijs.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a vanilla site that can be deployed with ZE
Deploy your own vanilla website, along with Serverless Functions, with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/vanilla)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/vanilla)
_Live Example: https://vanilla.now-examples.now.sh_

View File

@@ -1,4 +1,4 @@
![Vue.js Logo](../../packages/frameworks/logos/vue.svg)
![Vue.js Logo](https://github.com/zeit/now/blob/master/packages/frameworks/logos/vue.svg)
# Vue.js Example
@@ -8,7 +8,7 @@ This directory is a brief example of a [Vue.js](https://vuejs.org/) app that can
Deploy your own Vue.js project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/vue)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/vue)
_Live Example: https://vue.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [VuePress](https://vuepress.vuejs.org/) a
Deploy your own VuePress project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/vuepress)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/vuepress)
_Live Example: https://vuepress.now-examples.now.sh_

View File

@@ -6,7 +6,7 @@ This directory is a brief example of a [Zola](https://www.getzola.org/) site tha
Deploy your own Zola project with ZEIT Now.
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/new/project?template=https://github.com/zeit/now/tree/master/examples/zola)
[![Deploy with ZEIT Now](https://zeit.co/button)](https://zeit.co/import/project?template=https://github.com/zeit/now/tree/master/examples/zola)
_Live Example: https://zola.now-examples.now.sh_

View File

@@ -1,15 +1,18 @@
{
"redirects": [
"rewrites": [
{
"source": "/",
"destination": "https://zeit.co/new",
"statusCode": 307
"destination": "/api/frameworks"
}
],
"env": {
"GITHUB_ACCESS_TOKEN": "@now-api-examples-github-token",
"SENTRY_DSN": "@sentry-product-dsn"
},
"github": {
"silent": true,
"autoJobCancelation": true
},
"headers": [
{
"source": "/api/frameworks",

View File

@@ -32,7 +32,7 @@
"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",
"publish-from-github": "./utils/publish.sh",
"changelog": "node utils/changelog.js",
"build": "node utils/run.js build all",
"test-lint": "node utils/run.js test-lint",
@@ -91,6 +91,7 @@
"@typescript-eslint/camelcase": 0,
"@typescript-eslint/explicit-function-return-type": 0,
"@typescript-eslint/no-empty-function": 0,
"@typescript-eslint/no-unused-vars": 2,
"@typescript-eslint/no-use-before-define": 0
},
"overrides": [

View File

@@ -17,7 +17,7 @@
},
"settings": {
"buildCommand": {
"placeholder": "`next build` or `build` from `package.json`"
"placeholder": "`build` from `package.json` or `next build`"
},
"devCommand": {
"value": "next dev --port $PORT"
@@ -580,7 +580,7 @@
},
"settings": {
"buildCommand": {
"value": "hugo"
"value": "hugo -D --gc"
},
"devCommand": {
"value": "hugo server -D -w -p $PORT"
@@ -808,5 +808,22 @@
"logo": "https://raw.githubusercontent.com/zeit/now/master/packages/frameworks/logos/foundation.svg",
"tagline": "Foundation is the most advanced responsive front-end framework in the world.",
"description": "A Foundation app, created with the Foundation CLI."
},
{
"name": "Other",
"slug": null,
"logo": "https://raw.githubusercontent.com/zeit/now/master/packages/frameworks/logos/other.svg",
"description": "No framework or a unoptimized framework.",
"settings": {
"buildCommand": {
"placeholder": "`build` or `now-build` from `package.json` if it exists"
},
"devCommand": {
"placeholder": "None"
},
"outputDirectory": {
"placeholder": "`public` if it exists, or `.`"
}
}
}
]

View File

@@ -13,11 +13,11 @@ export type Setting = SettingValue | SettingPlaceholder;
export interface Framework {
name: string;
slug: string;
slug: string | null;
logo: string;
demo: string;
tagline: string;
website: string;
demo?: string;
tagline?: string;
website?: string;
description: string;
detectors?: {
every?: FrameworkDetectionItem[];

View File

@@ -0,0 +1,3 @@
<svg width="20" height="20" viewBox="0 0 20 20" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M10 4L16 15H4L10 4Z" stroke="#666666" stroke-dasharray="2 2"/>
</svg>

After

Width:  |  Height:  |  Size: 215 B

View File

@@ -1,6 +1,6 @@
{
"name": "@now/frameworks",
"version": "0.0.6",
"version": "0.0.10",
"main": "frameworks.json",
"license": "UNLICENSED"
}

View File

@@ -1,6 +1,6 @@
{
"name": "@now/build-utils",
"version": "1.3.6",
"version": "2.1.0",
"license": "MIT",
"main": "./dist/index.js",
"types": "./dist/index.d.js",

File diff suppressed because it is too large Load Diff

View File

@@ -1,423 +0,0 @@
import { parse as parsePath } from 'path';
import { Route, Source } from '@now/routing-utils';
import { Builder } from './types';
import { getIgnoreApiFilter, sortFiles } from './detect-builders';
function escapeName(name: string) {
const special = '[]^$.|?*+()'.split('');
for (const char of special) {
name = name.replace(new RegExp(`\\${char}`, 'g'), `\\${char}`);
}
return name;
}
function joinPath(...segments: string[]) {
const joinedPath = segments.join('/');
return joinedPath.replace(/\/{2,}/g, '/');
}
function concatArrayOfText(texts: string[]): string {
if (texts.length <= 2) {
return texts.join(' and ');
}
const last = texts.pop();
return `${texts.join(', ')}, and ${last}`;
}
// Takes a filename or foldername, strips the extension
// gets the part between the "[]" brackets.
// It will return `null` if there are no brackets
// and therefore no segment.
function getSegmentName(segment: string): string | null {
const { name } = parsePath(segment);
if (name.startsWith('[') && name.endsWith(']')) {
return name.slice(1, -1);
}
return null;
}
function createRouteFromPath(
filePath: string,
featHandleMiss: boolean,
cleanUrls: boolean
): { route: Source; isDynamic: boolean } {
const parts = filePath.split('/');
let counter = 1;
const query: string[] = [];
let isDynamic = false;
const srcParts = parts.map((segment, i): string => {
const name = getSegmentName(segment);
const isLast = i === parts.length - 1;
if (name !== null) {
// We can't use `URLSearchParams` because `$` would get escaped
query.push(`${name}=$${counter++}`);
isDynamic = true;
return `([^/]+)`;
} else if (isLast) {
const { name: fileName, ext } = parsePath(segment);
const isIndex = fileName === 'index';
const prefix = isIndex ? '\\/' : '';
const names = [
isIndex ? prefix : `${fileName}\\/`,
prefix + escapeName(fileName),
featHandleMiss && cleanUrls
? ''
: prefix + escapeName(fileName) + escapeName(ext),
].filter(Boolean);
// Either filename with extension, filename without extension
// or nothing when the filename is `index`.
// When `cleanUrls: true` then do *not* add the filename with extension.
return `(${names.join('|')})${isIndex ? '?' : ''}`;
}
return segment;
});
const { name: fileName, ext } = parsePath(filePath);
const isIndex = fileName === 'index';
const queryString = `${query.length ? '?' : ''}${query.join('&')}`;
const src = isIndex
? `^/${srcParts.slice(0, -1).join('/')}${srcParts.slice(-1)[0]}$`
: `^/${srcParts.join('/')}$`;
let route: Source;
if (featHandleMiss) {
const extensionless = ext ? filePath.slice(0, -ext.length) : filePath;
route = {
src,
dest: `/${extensionless}${queryString}`,
check: true,
};
} else {
route = {
src,
dest: `/${filePath}${queryString}`,
};
}
return { route, isDynamic };
}
// Check if the path partially matches and has the same
// name for the path segment at the same position
function partiallyMatches(pathA: string, pathB: string): boolean {
const partsA = pathA.split('/');
const partsB = pathB.split('/');
const long = partsA.length > partsB.length ? partsA : partsB;
const short = long === partsA ? partsB : partsA;
let index = 0;
for (const segmentShort of short) {
const segmentLong = long[index];
const nameLong = getSegmentName(segmentLong);
const nameShort = getSegmentName(segmentShort);
// If there are no segments or the paths differ we
// return as they are not matching
if (segmentShort !== segmentLong && (!nameLong || !nameShort)) {
return false;
}
if (nameLong !== nameShort) {
return true;
}
index += 1;
}
return false;
}
// 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 => {
const { dir, name } = parsePath(unresolvedPath);
const parts = joinPath(dir, name).split('/');
return parts.map(part => part.replace(/\[.*\]/, '1')).join('/');
};
const currentAbsolutePath = getAbsolutePath(filePath);
return files.reduce((prev: string[], file: string): string[] => {
const absolutePath = getAbsolutePath(file);
if (absolutePath === currentAbsolutePath) {
prev.push(file);
} else if (partiallyMatches(filePath, file)) {
prev.push(file);
}
return prev;
}, []);
}
// Checks if a placeholder with the same name is used
// multiple times inside the same path
function getConflictingSegment(filePath: string): string | null {
const segments = new Set<string>();
for (const segment of filePath.split('/')) {
const name = getSegmentName(segment);
if (name !== null && segments.has(name)) {
return name;
}
if (name) {
segments.add(name);
}
}
return null;
}
function sortFilesBySegmentCount(fileA: string, fileB: string): number {
const lengthA = fileA.split('/').length;
const lengthB = fileB.split('/').length;
if (lengthA > lengthB) {
return -1;
}
if (lengthA < lengthB) {
return 1;
}
// Paths that have the same segment length but
// less placeholders are preferred
const countSegments = (prev: number, segment: string) =>
getSegmentName(segment) ? prev + 1 : 0;
const segmentLengthA = fileA.split('/').reduce(countSegments, 0);
const segmentLengthB = fileB.split('/').reduce(countSegments, 0);
if (segmentLengthA > segmentLengthB) {
return 1;
}
if (segmentLengthA < segmentLengthB) {
return -1;
}
return 0;
}
interface ApiRoutesResult {
defaultRoutes: Source[] | null;
dynamicRoutes: Source[] | null;
error: { [key: string]: string } | null;
}
interface RoutesResult {
defaultRoutes: Route[] | null;
redirectRoutes: Route[] | null;
error: { [key: string]: string } | null;
}
async function detectApiRoutes(
files: string[],
builders: Builder[],
featHandleMiss: boolean,
cleanUrls: boolean
): Promise<ApiRoutesResult> {
if (!files || files.length === 0) {
return {
defaultRoutes: null,
dynamicRoutes: null,
error: null,
};
}
// The deepest routes need to be
// the first ones to get handled
const sortedFiles = files
.filter(getIgnoreApiFilter(builders))
.sort(sortFiles)
.sort(sortFilesBySegmentCount);
const defaultRoutes: Source[] = [];
const dynamicRoutes: Source[] = [];
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/') &&
!builders.some(b => b.src === file && b.config && b.config.functions)
) {
continue;
}
const conflictingSegment = getConflictingSegment(file);
if (conflictingSegment) {
return {
defaultRoutes: null,
dynamicRoutes: null,
error: {
code: 'conflicting_path_segment',
message:
`The segment "${conflictingSegment}" occurs more than ` +
`one time in your path "${file}". Please make sure that ` +
`every segment in a path is unique`,
},
};
}
const occurrences = pathOccurrences(file, sortedFiles).filter(
name => name !== file
);
if (occurrences.length > 0) {
const messagePaths = concatArrayOfText(
occurrences.map(name => `"${name}"`)
);
return {
defaultRoutes: null,
dynamicRoutes: null,
error: {
code: 'conflicting_file_path',
message:
`Two or more files have conflicting paths or names. ` +
`Please make sure path segments and filenames, without their extension, are unique. ` +
`The path "${file}" has conflicts with ${messagePaths}`,
},
};
}
const out = createRouteFromPath(file, featHandleMiss, cleanUrls);
if (out.isDynamic) {
dynamicRoutes.push(out.route);
}
defaultRoutes.push(out.route);
}
return { defaultRoutes, dynamicRoutes, error: null };
}
function getPublicBuilder(builders: Builder[]): Builder | null {
const builder = builders.find(
builder =>
builder.use === '@now/static' &&
/^.*\/\*\*\/\*$/.test(builder.src) &&
builder.config &&
builder.config.zeroConfig === true
);
return builder || null;
}
export function detectOutputDirectory(builders: Builder[]): string | null {
// TODO: We eventually want to save the output directory to
// builder.config.outputDirectory so it is only detected once
const publicBuilder = getPublicBuilder(builders);
return publicBuilder ? publicBuilder.src.replace('/**/*', '') : null;
}
export function detectApiDirectory(builders: Builder[]): string | null {
// TODO: We eventually want to save the api directory to
// builder.config.apiDirectory so it is only detected once
const isZeroConfig = builders.some(b => b.config && b.config.zeroConfig);
return isZeroConfig ? 'api' : null;
}
export async function detectRoutes(
files: string[],
builders: Builder[],
featHandleMiss = false,
cleanUrls = false,
trailingSlash?: boolean
): Promise<RoutesResult> {
const result = await detectApiRoutes(
files,
builders,
featHandleMiss,
cleanUrls
);
const { dynamicRoutes, defaultRoutes: allRoutes, error } = result;
if (error) {
return { defaultRoutes: null, redirectRoutes: null, error };
}
const directory = detectOutputDirectory(builders);
const defaultRoutes: Route[] = [];
const redirectRoutes: Route[] = [];
if (allRoutes && allRoutes.length > 0) {
const hasApiRoutes = allRoutes.some(
r => r.dest && r.dest.startsWith('/api/')
);
if (featHandleMiss) {
defaultRoutes.push({ handle: 'miss' });
const extSet = new Set(
builders
.filter(b => b.src && b.src.startsWith('api/'))
.map(b => parsePath(b.src).ext)
.filter(Boolean)
);
if (extSet.size > 0) {
const exts = Array.from(extSet)
.map(ext => ext.slice(1))
.join('|');
const extGroup = `(?:\\.(?:${exts}))`;
if (cleanUrls) {
redirectRoutes.push({
src: `^/(api(?:.+)?)/index${extGroup}?/?$`,
headers: { Location: trailingSlash ? '/$1/' : '/$1' },
status: 308,
});
redirectRoutes.push({
src: `^/api/(.+)${extGroup}/?$`,
headers: { Location: trailingSlash ? '/api/$1/' : '/api/$1' },
status: 308,
});
} else {
defaultRoutes.push({
src: `^/api/(.+)${extGroup}$`,
dest: '/api/$1',
check: true,
});
}
}
if (dynamicRoutes) {
defaultRoutes.push(...dynamicRoutes);
}
if (hasApiRoutes) {
defaultRoutes.push({
src: '^/api(/.*)?$',
status: 404,
continue: true,
});
}
} else {
defaultRoutes.push(...allRoutes);
if (hasApiRoutes) {
defaultRoutes.push({
status: 404,
src: '^/api(/.*)?$',
});
}
}
}
if (!featHandleMiss && directory) {
defaultRoutes.push({
src: '/(.*)',
dest: `/${directory}/$1`,
});
}
return { defaultRoutes, redirectRoutes, error };
}

View File

@@ -5,7 +5,7 @@ import { promisify } from 'util';
import { lstat, Stats } from 'fs-extra';
import FileFsRef from '../file-fs-ref';
type GlobOptions = vanillaGlob_.IOptions;
export type GlobOptions = vanillaGlob_.IOptions;
interface FsFiles {
[filePath: string]: FileFsRef;

View File

@@ -206,10 +206,10 @@ export async function runNpmInstall(
debug(`Installing to ${destPath}`);
const { hasPackageLockJson } = await scanParentDirs(destPath);
const opts = { cwd: destPath, ...spawnOpts } || {
cwd: destPath,
env: process.env,
};
const opts: SpawnOptions = { cwd: destPath, ...spawnOpts };
const env = opts.env || { ...process.env };
delete env.NODE_ENV;
opts.env = env;
if (hasPackageLockJson) {
commandArgs = args.filter(a => a !== '--prefer-offline');
@@ -239,10 +239,7 @@ export async function runBundleInstall(
}
assert(path.isAbsolute(destPath));
const opts = { cwd: destPath, ...spawnOpts } || {
cwd: destPath,
env: process.env,
};
const opts = { cwd: destPath, ...spawnOpts };
await spawnAsync(
'bundle',
@@ -270,10 +267,7 @@ export async function runPipInstall(
}
assert(path.isAbsolute(destPath));
const opts = { cwd: destPath, ...spawnOpts } || {
cwd: destPath,
env: process.env,
};
const opts = { cwd: destPath, ...spawnOpts };
await spawnAsync(
'pip3',

View File

@@ -5,7 +5,7 @@ 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 glob, { GlobOptions } from './fs/glob';
import rename from './fs/rename';
import {
execAsync,
@@ -40,6 +40,7 @@ export {
DownloadedFiles,
getWriteableDirectory,
glob,
GlobOptions,
rename,
execAsync,
spawnAsync,
@@ -63,11 +64,11 @@ export {
};
export {
detectRoutes,
detectBuilders,
detectOutputDirectory,
detectApiDirectory,
} from './detect-routes';
export { detectBuilders } from './detect-builders';
detectApiExtensions,
} from './detect-builders';
export { detectFramework } from './detect-framework';
export { DetectorFilesystem } from './detectors/filesystem';
export { readConfigFile } from './fs/read-config-file';

View File

@@ -4,20 +4,28 @@ import FileRef from './file-ref';
import { Lambda } from './lambda';
interface PrerenderOptions {
expiration: number;
expiration: number | false;
lambda: Lambda;
fallback: FileBlob | FileFsRef | FileRef | null;
group?: number;
bypassToken?: string | null /* optional to be non-breaking change */;
}
export class Prerender {
public type: 'Prerender';
public expiration: number;
public expiration: number | false;
public lambda: Lambda;
public fallback: FileBlob | FileFsRef | FileRef | null;
public group?: number;
public bypassToken: string | null;
constructor({ expiration, lambda, fallback, group }: PrerenderOptions) {
constructor({
expiration,
lambda,
fallback,
group,
bypassToken,
}: PrerenderOptions) {
this.type = 'Prerender';
this.expiration = expiration;
this.lambda = lambda;
@@ -32,6 +40,22 @@ export class Prerender {
}
this.group = group;
if (bypassToken == null) {
this.bypassToken = null;
} else if (typeof bypassToken === 'string') {
if (bypassToken.length < 32) {
// Enforce 128 bits of entropy for safety reasons (UUIDv4 size)
throw new Error(
'The `bypassToken` argument for `Prerender` must be 32 characters or more.'
);
}
this.bypassToken = bypassToken;
} else {
throw new Error(
'The `bypassToken` argument for `Prerender` must be a `string`.'
);
}
if (typeof fallback === 'undefined') {
throw new Error(
'The `fallback` argument for `Prerender` needs to be a `FileBlob`, `FileFsRef`, `FileRef`, or null.'

View File

@@ -31,6 +31,7 @@ export interface Config {
| undefined;
maxLambdaSize?: string;
includeFiles?: string | string[];
excludeFiles?: string | string[];
bundle?: boolean;
ldsflags?: string;
helpers?: boolean;

View File

@@ -0,0 +1,21 @@
function checkPkgOrThrow(pkgname) {
try {
const dep = require(pkgname);
if (!dep) {
throw new Error('Undefined');
}
} catch (e) {
console.error(`Expected package "${pkgname}" to be installed.`);
process.exit(1);
}
}
// We expect both `dependencies` and `devDependencies` to be installed
// even when NODE_ENV=production.
checkPkgOrThrow('tls-check');
checkPkgOrThrow('exeggcute');
// This is to satisfy `@now/static-build` which needs a `dist` directory.
const { exec } = require('exeggcute');
exec('mkdir dist', __dirname);
exec('echo "node-env:RANDOMNESS_PLACEHOLDER" > dist/index.html', __dirname);

View File

@@ -0,0 +1,6 @@
{
"version": 2,
"builds": [{ "src": "package.json", "use": "@now/static-build" }],
"build": { "env": { "NODE_ENV": "production" } },
"probes": [{ "path": "/", "mustContain": "node-env:RANDOMNESS_PLACEHOLDER" }]
}

View File

@@ -0,0 +1,12 @@
{
"private": true,
"scripts": {
"build": "node build.js"
},
"dependencies": {
"tls-check": "1.0.0"
},
"devDependencies": {
"exeggcute": "1.0.0"
}
}

View File

@@ -4,7 +4,7 @@ const {
packAndDeploy,
testDeployment,
} = require('../../../test/lib/deployment/test-deployment');
const { glob, detectBuilders, detectRoutes } = require('../');
const { glob, detectBuilders } = require('../');
jest.setTimeout(4 * 60 * 1000);
@@ -110,8 +110,7 @@ it('Test `detectBuilders` and `detectRoutes`', async () => {
},
];
const { builders } = await detectBuilders(files, pkg);
const { defaultRoutes } = await detectRoutes(files, builders);
const { builders, defaultRoutes } = await detectBuilders(files, pkg);
const nowConfig = { builds: builders, routes: defaultRoutes, probes };
await fs.writeFile(
@@ -126,7 +125,7 @@ it('Test `detectBuilders` and `detectRoutes`', async () => {
expect(deployment).toBeDefined();
});
it('Test `detectBuilders` and `detectRoutes` with `index` files', async () => {
it('Test `detectBuilders` with `index` files', async () => {
const fixture = path.join(__dirname, 'fixtures', '02-zero-config-api');
const pkg = await fs.readJSON(path.join(fixture, 'package.json'));
const fileList = await glob('**', fixture);
@@ -192,8 +191,7 @@ it('Test `detectBuilders` and `detectRoutes` with `index` files', async () => {
},
];
const { builders } = await detectBuilders(files, pkg);
const { defaultRoutes } = await detectRoutes(files, builders);
const { builders, defaultRoutes } = await detectBuilders(files, pkg);
const nowConfig = { builds: builders, routes: defaultRoutes, probes };
await fs.writeFile(

File diff suppressed because it is too large Load Diff

View File

@@ -11,6 +11,10 @@ const {
} = require('../dist');
it('should re-create symlinks properly', async () => {
if (process.platform === 'win32') {
console.log('Skipping test on windows');
return;
}
const files = await glob('**', path.join(__dirname, 'symlinks'));
assert.equal(Object.keys(files).length, 2);
@@ -29,6 +33,10 @@ it('should re-create symlinks properly', async () => {
});
it('should create zip files with symlinks properly', async () => {
if (process.platform === 'win32') {
console.log('Skipping test on windows');
return;
}
const files = await glob('**', path.join(__dirname, 'symlinks'));
assert.equal(Object.keys(files).length, 2);
@@ -116,10 +124,7 @@ it('should throw for discontinued versions', async () => {
const realDateNow = Date.now.bind(global.Date);
global.Date.now = () => new Date('2020-02-14').getTime();
expect(getSupportedNodeVersion('', false)).rejects.toThrow();
expect(getSupportedNodeVersion('8.10.x', false)).rejects.toThrow();
expect(getSupportedNodeVersion('', true)).rejects.toThrow();
expect(getSupportedNodeVersion('8.10.x', true)).rejects.toThrow();
expect(getDiscontinuedNodeVersions().length).toBe(1);

View File

@@ -1,6 +1,6 @@
{
"name": "@now/cgi",
"version": "1.0.1",
"version": "1.0.3",
"license": "MIT",
"repository": {
"type": "git",

View File

@@ -15,7 +15,7 @@
"@zeit/best@0.4.3":
version "0.4.3"
resolved "http://registry.npmjs.org/@zeit/best/-/best-0.4.3.tgz#eaebdfa8b24121a97b1753501ea8c9330d549b30"
resolved "https://registry.npmjs.org/@zeit/best/-/best-0.4.3.tgz#eaebdfa8b24121a97b1753501ea8c9330d549b30"
dependencies:
arg "1.0.0"
chalk "2.3.1"
@@ -144,7 +144,7 @@ call-me-maybe@^1.0.1:
chalk@2.3.1:
version "2.3.1"
resolved "http://registry.npmjs.org/chalk/-/chalk-2.3.1.tgz#523fe2678aec7b04e8041909292fe8b17059b796"
resolved "https://registry.npmjs.org/chalk/-/chalk-2.3.1.tgz#523fe2678aec7b04e8041909292fe8b17059b796"
dependencies:
ansi-styles "^3.2.0"
escape-string-regexp "^1.0.5"
@@ -585,8 +585,8 @@ minimatch@^3.0.4:
brace-expansion "^1.1.7"
mixin-deep@^1.2.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.1.tgz#a49e7268dce1a0d9698e45326c5626df3543d0fe"
version "1.3.2"
resolved "https://registry.yarnpkg.com/mixin-deep/-/mixin-deep-1.3.2.tgz#1120b43dc359a785dce65b55b82e257ccf479566"
dependencies:
for-in "^1.0.2"
is-extendable "^1.0.1"
@@ -704,7 +704,7 @@ rmfr@2.0.0:
safe-regex@^1.1.0:
version "1.1.0"
resolved "http://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e"
resolved "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz#40a3669f3b077d1e943d44629e157dd48023bf2e"
dependencies:
ret "~0.1.10"

View File

@@ -0,0 +1,10 @@
declare module 'is-port-reachable' {
export interface IsPortReachableOptions {
timeout?: number | undefined;
host?: string;
}
export default function(
port: number | undefined,
options?: IsPortReachableOptions
): Promise<boolean>;
}

View File

@@ -1,4 +1,4 @@
![now](https://assets.zeit.co/image/upload/v1542240976/repositories/now-cli/now-cli-repo-banner-v3.png)
![now](https://assets.zeit.co/image/upload/v1581518533/repositories/now-cli/v4.png)
[![Join the community on Spectrum](https://withspectrum.github.io/badge/badge.svg)](https://spectrum.chat/zeit)

View File

@@ -1,6 +1,6 @@
{
"name": "now",
"version": "17.0.0-canary.14",
"version": "17.0.5-canary.5",
"preferGlobal": true,
"license": "Apache-2.0",
"description": "The command-line interface for Now",
@@ -12,7 +12,7 @@
},
"scripts": {
"preinstall": "node ./scripts/preinstall.js",
"test-unit": "nyc ava test/*unit.js --serial --fail-fast --verbose",
"test-unit": "nyc ava test/unit.js test/dev-builder.unit.js test/dev-router.unit.js test/dev-server.unit.js --serial --fail-fast --verbose",
"test-integration": "ava test/integration.js --serial --fail-fast",
"test-integration-v1": "ava test/integration-v1.js --serial --fail-fast",
"test-integration-now-dev": "ava test/dev/integration.js --serial --fail-fast --verbose",
@@ -59,10 +59,11 @@
]
},
"engines": {
"node": ">= 8"
"node": ">= 10"
},
"devDependencies": {
"@sentry/node": "5.5.0",
"@sindresorhus/slugify": "0.10.0",
"@types/ansi-escapes": "3.0.0",
"@types/ansi-regex": "4.0.0",
"@types/async-retry": "1.2.1",
@@ -89,10 +90,10 @@
"@types/tar-fs": "1.16.1",
"@types/text-table": "0.2.0",
"@types/universal-analytics": "0.4.2",
"@types/which": "1.3.1",
"@types/which": "1.3.2",
"@types/write-json-file": "2.2.1",
"@zeit/dockerignore": "0.0.5",
"@zeit/fun": "0.11.0",
"@zeit/fun": "0.11.2",
"@zeit/ncc": "0.18.5",
"@zeit/source-map-support": "0.6.2",
"ajv": "6.10.2",
@@ -108,7 +109,7 @@
"chalk": "2.4.2",
"chokidar": "2.1.6",
"clipboardy": "2.1.0",
"codecov": "3.1.0",
"codecov": "3.6.5",
"cpy": "7.2.0",
"credit-card": "3.0.1",
"date-fns": "1.29.0",
@@ -126,11 +127,13 @@
"esm": "3.1.4",
"execa": "3.2.0",
"fs-extra": "7.0.1",
"get-port": "5.1.1",
"glob": "7.1.2",
"http-proxy": "1.17.0",
"ignore": "4.0.6",
"ini": "1.3.4",
"inquirer": "3.3.0",
"inquirer": "7.0.4",
"is-port-reachable": "3.0.0",
"is-url": "1.2.2",
"jaro-winkler": "0.2.8",
"jsonlines": "0.1.1",
@@ -172,10 +175,10 @@
"universal-analytics": "0.4.20",
"update-check": "1.5.3",
"utility-types": "2.1.0",
"which": "1.3.1",
"which": "2.0.2",
"which-promise": "1.0.0",
"write-json-file": "2.2.0",
"xdg-app-paths": "5.1.0",
"yarn": "1.17.3"
"yarn": "1.22.0"
}
}

View File

@@ -50,21 +50,23 @@ async function createBuildersTarball() {
async function main() {
const isDev = process.argv[2] === '--dev';
// Create a tarball from all the `@now` scoped builders which will be bundled
// with Now CLI
await createBuildersTarball();
if (!isDev) {
// Create a tarball from all the `@now` scoped builders which will be bundled
// with Now CLI
await createBuildersTarball();
// `now dev` uses chokidar to watch the filesystem, but opts-out of the
// `fsevents` feature using `useFsEvents: false`, so delete the module here so
// that it is not compiled by ncc, which makes the npm package size larger
// than necessary.
await remove(join(dirRoot, '../../node_modules/fsevents'));
// `now dev` uses chokidar to watch the filesystem, but opts-out of the
// `fsevents` feature using `useFsEvents: false`, so delete the module here so
// that it is not compiled by ncc, which makes the npm package size larger
// than necessary.
await remove(join(dirRoot, '../../node_modules/fsevents'));
// Compile the `doT.js` template files for `now dev`
console.log();
await execa(process.execPath, [join(__dirname, 'compile-templates.js')], {
stdio: 'inherit',
});
// Compile the `doT.js` template files for `now dev`
console.log();
await execa(process.execPath, [join(__dirname, 'compile-templates.js')], {
stdio: 'inherit',
});
}
// Do the initial `ncc` build
console.log();

View File

@@ -1,25 +1,3 @@
#!/usr/bin/env node
// This should only be used for the integration tests
const { join } = require('path');
const { spawnSync } = require('child_process');
const match = process.version.match(/^v(\d+)\.(\d+)/);
const major = match && parseInt(match[1], 10);
// Must be above or equal to 10.10.0
// const isVersion = major > 10 || (major === 10 && minor >= 10);
if (major === 8 && process.platform === 'darwin') {
const [node, _, ...args] = process.argv; // eslint-disable-line @typescript-eslint/no-unused-vars
const script = join(__dirname, '../dist/index.js');
const { status } = spawnSync(node, ['--no-warnings', script, ...args], {
stdio: 'inherit'
});
process.exit(status);
} else {
require('../dist/index.js');
}
require('../dist/index.js');

View File

@@ -8,12 +8,11 @@ import getAliases from '../../util/alias/get-aliases';
import getScope from '../../util/get-scope.ts';
import stamp from '../../util/output/stamp.ts';
import strlen from '../../util/strlen.ts';
import wait from '../../util/output/wait';
export default async function ls(ctx, opts, args, output) {
const {
authConfig: { token },
config
config,
} = ctx;
const { currentTeam } = config;
const { apiUrl } = ctx;
@@ -22,7 +21,7 @@ export default async function ls(ctx, opts, args, output) {
apiUrl,
token,
currentTeam,
debug: debugEnabled
debug: debugEnabled,
});
let contextName = null;
@@ -51,7 +50,7 @@ export default async function ls(ctx, opts, args, output) {
return 1;
}
cancelWait = wait(
cancelWait = output.spinner(
args[0]
? `Fetching alias details for "${args[0]}" under ${chalk.bold(
contextName
@@ -112,13 +111,13 @@ function printAliasTable(aliases) {
? a.deployment.url
: chalk.gray(''),
a.alias,
ms(Date.now() - new Date(a.created))
])
ms(Date.now() - new Date(a.created)),
]),
],
{
align: ['l', 'l', 'r'],
hsep: ' '.repeat(4),
stringLength: strlen
stringLength: strlen,
}
).replace(/^/gm, ' ')}\n\n`;
}
@@ -130,13 +129,13 @@ function printPathAliasTable(rules) {
rules.map(rule => [
rule.pathname ? rule.pathname : chalk.cyan('[fallthrough]'),
rule.method ? rule.method : '*',
rule.dest
rule.dest,
])
),
{
align: ['l', 'l', 'l', 'l'],
hsep: ' '.repeat(6),
stringLength: strlen
stringLength: strlen,
}
).replace(/^(.*)/gm, ' $1')}\n`;
}

View File

@@ -21,7 +21,7 @@ export default async function({ creditCards, clear = false, contextName }) {
name: {
label: rightPad('Full Name', 12),
placeholder: 'John Appleseed',
validateValue: data => data.trim().length > 0
validateValue: data => data.trim().length > 0,
},
cardNumber: {
@@ -36,7 +36,7 @@ export default async function({ creditCards, clear = false, contextName }) {
return false;
}
return ccValidator.isValidCardNumber(data, type);
}
},
},
ccv: {
@@ -46,7 +46,7 @@ export default async function({ creditCards, clear = false, contextName }) {
validateValue: data => {
const brand = state.cardNumber.brand.toLowerCase();
return ccValidator.doesCvvMatchType(data, brand);
}
},
},
expDate: {
@@ -54,8 +54,8 @@ export default async function({ creditCards, clear = false, contextName }) {
mask: 'expDate',
placeholder: 'mm / yyyy',
middleware: expDateMiddleware,
validateValue: data => !ccValidator.isExpired(...data.split(' / '))
}
validateValue: data => !ccValidator.isExpired(...data.split(' / ')),
},
};
async function render() {
@@ -80,7 +80,7 @@ export default async function({ creditCards, clear = false, contextName }) {
mask: piece.mask,
validateKeypress: piece.validateKeypress,
validateValue: piece.validateValue,
autoComplete: piece.autoComplete
autoComplete: piece.autoComplete,
});
piece.value = result;
@@ -135,7 +135,7 @@ export default async function({ creditCards, clear = false, contextName }) {
name: state.name.value,
cardNumber: state.cardNumber.value,
ccv: state.ccv.value,
expDate: state.expDate.value
expDate: state.expDate.value,
});
stopSpinner();
@@ -156,9 +156,9 @@ export default async function({ creditCards, clear = false, contextName }) {
stopSpinner();
const linesToClear = state.error ? 15 : 14;
process.stdout.write(ansiEscapes.eraseLines(linesToClear));
state.error = `${chalk.red(
'> Error!'
)} ${err.message} Please make sure the info is correct`;
state.error = `${chalk.red('> Error!')} ${
err.message
} Please make sure the info is correct`;
await render();
}
}

View File

@@ -5,14 +5,11 @@ import Now from '../../util';
import Client from '../../util/client';
import getScope from '../../util/get-scope';
import stamp from '../../util/output/stamp';
import wait from '../../util/output/wait';
import createCertFromFile from '../../util/certs/create-cert-from-file';
import createCertForCns from '../../util/certs/create-cert-for-cns';
import { NowContext } from '../../types';
import { Output } from '../../util/output';
import { DomainPermissionDenied, InvalidCert } from '../../util/errors-ts';
interface Options {
'--overwrite'?: boolean;
'--debug'?: boolean;
@@ -88,7 +85,7 @@ async function add(
}
// Create a custom certificate from the given file paths
cert = await createCertFromFile(now, keyPath, crtPath, caPath, contextName);
cert = await createCertFromFile(now, keyPath, crtPath, caPath);
} else {
output.warn(
`${chalk.cyan(
@@ -112,7 +109,7 @@ async function add(
(res, item) => res.concat(item.split(',')),
[]
);
const cancelWait = wait(
const cancelWait = output.spinner(
`Generating a certificate for ${chalk.bold(cns.join(', '))}`
);

View File

@@ -87,13 +87,7 @@ export default async function issue(
}
// Create a custom certificate from the given file paths
cert = await createCertFromFile(
client,
keyPath,
crtPath,
caPath,
contextName
);
cert = await createCertFromFile(client, keyPath, crtPath, caPath);
if (cert instanceof Error) {
output.error(cert.message);

View File

@@ -38,7 +38,6 @@ export const latestHelp = () => `
-h, --help Output usage information
-v, --version Output the version number
-V, --platform-version Set the platform version to deploy to
-n, --name Set the project name of the deployment
-A ${chalk.bold.underline('FILE')}, --local-config=${chalk.bold.underline(
'FILE'
)} Path to the local ${'`now.json`'} file
@@ -66,6 +65,7 @@ export const latestHelp = () => `
-S, --scope Set a custom scope
--regions Set default regions to enable the deployment on
--prod Create a production deployment
-c, --confirm Confirm default options and skip questions
${note(
`To view the usage information for Now 1.0, run ${code(
@@ -96,7 +96,6 @@ export const latestHelp = () => `
`;
export const latestArgs = {
'--name': String,
'--force': Boolean,
'--public': Boolean,
'--no-clipboard': Boolean,
@@ -107,10 +106,8 @@ export const latestArgs = {
// This is not an array in favor of matching
// the config property name.
'--regions': String,
'--target': String,
'--prod': Boolean,
'--confirm': Boolean,
'-n': '--name',
'-f': '--force',
'-p': '--public',
'-e': '--env',
@@ -118,6 +115,11 @@ export const latestArgs = {
'-C': '--no-clipboard',
'-m': '--meta',
'-c': '--confirm',
// deprecated
'--name': String,
'-n': '--name',
'--target': String,
};
export const legacyArgsMri = {

View File

@@ -186,8 +186,7 @@ export default async ctx => {
contextName,
output,
stats,
localConfig || {},
isFile,
localConfig,
parts.latestArgs
);
}

View File

@@ -1,5 +1,6 @@
import ms from 'ms';
import bytes from 'bytes';
import { join } from 'path';
import { write as copy } from 'clipboardy';
import chalk from 'chalk';
import title from 'title';
@@ -47,8 +48,12 @@ import {
import getProjectName from '../../util/get-project-name';
import selectOrg from '../../util/input/select-org';
import inputProject from '../../util/input/input-project';
import validatePaths from '../../util/validate-paths';
import { prependEmoji, emoji } from '../../util/emoji';
import { inputRootDirectory } from '../../util/input/input-root-directory';
import validatePaths, {
validateRootDirectory,
} from '../../util/validate-paths';
import { readLocalConfig } from '../../util/config/files';
const addProcessEnv = async (log, env) => {
let val;
@@ -90,7 +95,7 @@ const printDeploymentStatus = async (
},
deployStamp,
isClipboardEnabled,
quiet
isFile
) => {
const isProdDeployment = target === 'production';
@@ -113,7 +118,7 @@ const printDeploymentStatus = async (
// print preview/production url
let previewUrl;
let isWildcard;
if (Array.isArray(aliasList) && aliasList.length > 0) {
if (!isFile && Array.isArray(aliasList) && aliasList.length > 0) {
// search for a non now.sh/non wildcard domain
// but fallback to the first alias in the list
const mainAlias =
@@ -130,22 +135,22 @@ const printDeploymentStatus = async (
}
// copy to clipboard
let isCopiedToClipboard = false;
if (isClipboardEnabled && !isWildcard) {
await copy(previewUrl).catch(error =>
output.debug(`Error copying to clipboard: ${error}`)
);
}
// write to stdout
if (quiet) {
process.stdout.write(`https://${deploymentUrl}`);
await copy(previewUrl)
.then(() => {
isCopiedToClipboard = true;
})
.catch(error => output.debug(`Error copying to clipboard: ${error}`));
}
output.print(
prependEmoji(
`${isProdDeployment ? 'Production' : 'Preview'}: ${chalk.bold(
previewUrl
)} ${deployStamp()}`,
)}${
isCopiedToClipboard ? chalk.gray(` [copied to clipboard]`) : ''
} ${deployStamp()}`,
emoji('success')
) + `\n`
);
@@ -201,7 +206,6 @@ export default async function main(
output,
stats,
localConfig,
isFile,
args
) {
let argv = null;
@@ -224,26 +228,161 @@ export default async function main(
// $FlowFixMe
const isTTY = process.stdout.isTTY;
const quiet = !isTTY;
const autoConfirm = argv['--confirm'];
// check paths
const path = await validatePaths(output, paths);
if (typeof path === 'number') {
return path;
const pathValidation = await validatePaths(output, paths);
if (!pathValidation.valid) {
return pathValidation.exitCode;
}
// build `meta`
const meta = Object.assign(
{},
parseMeta(localConfig.meta),
parseMeta(argv['--meta'])
);
const { isFile, path } = pathValidation;
const autoConfirm = argv['--confirm'] || isFile;
// --no-scale
if (argv['--no-scale']) {
warn(`The option --no-scale is only supported on Now 1.0 deployments`);
}
// deprecate --name
if (argv['--name']) {
output.print(
`${prependEmoji(
`The ${param('--name')} flag is deprecated (https://zeit.ink/1B)`,
emoji('warning')
)}\n`
);
}
const client = new Client({
apiUrl: ctx.apiUrl,
token: ctx.authConfig.token,
debug: debugEnabled,
});
// retrieve `project` and `org` from .now
const link = await getLinkedProject(output, client, path);
if (link.status === 'error') {
return link.exitCode;
}
let { org, project, status } = link;
let newProjectName = null;
let rootDirectory = project ? project.rootDirectory : null;
if (status === 'not_linked') {
const shouldStartSetup =
autoConfirm ||
(await confirm(
`Set up and deploy ${chalk.cyan(`${toHumanPath(path)}`)}?`,
true
));
if (!shouldStartSetup) {
output.print(`Aborted. Project not set up.\n`);
return 0;
}
org = await selectOrg(
output,
'Which scope do you want to deploy to?',
client,
ctx.config.currentTeam,
autoConfirm
);
// We use `localConfig` here to read the name
// even though the `now.json` file can change
// afterwards, this is fine since the property
// will be deprecated and can be replaced with
// user input.
const detectedProjectName = getProjectName({
argv,
nowConfig: localConfig || {},
isFile,
paths,
});
const projectOrNewProjectName = await inputProject(
output,
client,
org,
detectedProjectName,
autoConfirm
);
if (typeof projectOrNewProjectName === 'string') {
newProjectName = projectOrNewProjectName;
rootDirectory = await inputRootDirectory(path, output, autoConfirm);
} else {
project = projectOrNewProjectName;
rootDirectory = project.rootDirectory;
// we can already link the project
await linkFolderToProject(
output,
path,
{
projectId: project.id,
orgId: org.id,
},
project.name,
org.slug
);
status = 'linked';
}
}
const sourcePath = rootDirectory ? join(path, rootDirectory) : path;
if (
rootDirectory &&
(await validateRootDirectory(
output,
path,
sourcePath,
project
? `To change your project settings, go to https://zeit.co/${org.slug}/${project.name}/settings`
: ''
)) === false
) {
return 1;
}
// If Root Directory is used we'll try to read the config
// from there instead and use it if it exists.
if (rootDirectory) {
const rootDirectoryConfig = readLocalConfig(sourcePath);
if (rootDirectoryConfig) {
debug(`Read local config from root directory (${rootDirectory})`);
localConfig = rootDirectoryConfig;
} else if (localConfig) {
output.print(
`${prependEmoji(
`The ${highlight(
'now.json'
)} file should be inside of the provided root directory.`,
emoji('warning')
)}\n`
);
}
}
localConfig = localConfig || {};
if (localConfig.name) {
output.print(
`${prependEmoji(
`The ${code('name')} property in ${highlight(
'now.json'
)} is deprecated (https://zeit.ink/5F)`,
emoji('warning')
)}\n`
);
}
// build `env`
const isObject = item =>
Object.prototype.toString.call(item) === '[object Object]';
@@ -283,6 +422,13 @@ export default async function main(
}
}
// build `meta`
const meta = Object.assign(
{},
parseMeta(localConfig.meta),
parseMeta(argv['--meta'])
);
// Merge dotenv config, `env` from now.json, and `--env` / `-e` arguments
const deploymentEnv = Object.assign(
{},
@@ -340,81 +486,6 @@ export default async function main(
target = 'production';
}
const client = new Client({
apiUrl: ctx.apiUrl,
token: ctx.authConfig.token,
debug: debugEnabled,
});
// retrieve `project` and `org` from .now
let [org, project] = await getLinkedProject(client, path);
let newProjectName = null;
if (!org || !project) {
const { NOW_PROJECT_ID, NOW_ORG_ID } = process.env;
if (NOW_PROJECT_ID && NOW_ORG_ID) {
output.print(
`${chalk.red('Error!')} Project not found (${JSON.stringify({
NOW_PROJECT_ID,
NOW_ORG_ID,
})})\n`
);
return 1;
}
const shouldStartSetup =
autoConfirm ||
(await confirm(
`Set up and deploy ${chalk.cyan(`${toHumanPath(path)}`)}?`,
true
));
if (!shouldStartSetup) {
output.print(`Aborted. Project not set up.\n`);
return 0;
}
org = await selectOrg(
'Which scope do you want to deploy to?',
client,
ctx.config.currentTeam,
autoConfirm
);
const detectedProjectName = getProjectName({
argv,
nowConfig: localConfig,
isFile,
paths,
});
const projectOrNewProjectName = await inputProject(
output,
client,
org,
detectedProjectName,
autoConfirm
);
if (typeof projectOrNewProjectName === 'string') {
newProjectName = projectOrNewProjectName;
} else {
project = projectOrNewProjectName;
// we can already link the project
await linkFolderToProject(
output,
path,
{
projectId: project.id,
orgId: org.id,
},
project.name,
org.slug
);
}
}
const currentTeam = org.type === 'team' ? org.id : undefined;
const now = new Now({ apiUrl, token, debug: debugEnabled, currentTeam });
let deployStamp = stamp();
@@ -442,11 +513,11 @@ export default async function main(
output,
now,
contextName,
[path],
[sourcePath],
createArgs,
org,
autoConfirm,
!!newProjectName
!project && !isFile,
path
);
if (
@@ -455,6 +526,10 @@ export default async function main(
) {
let { projectSettings, framework } = deployment;
if (rootDirectory) {
projectSettings.rootDirectory = rootDirectory;
}
const settings = await editProjectSettings(
output,
projectSettings,
@@ -470,11 +545,11 @@ export default async function main(
output,
now,
contextName,
[path],
[sourcePath],
createArgs,
org,
!!newProjectName,
false
false,
path
);
}
@@ -483,6 +558,19 @@ export default async function main(
return 1;
}
if (deployment instanceof Error) {
output.error(
`${deployment.message ||
'An unexpected error occurred while deploying your project'} (http://zeit.ink/P4)`
);
return 1;
}
if (deployment.readyState === 'CANCELED') {
output.log('The deployment has been canceled');
return 1;
}
const deploymentResponse = await getDeploymentByIdOrHost(
now,
contextName,
@@ -569,7 +657,12 @@ export default async function main(
output.error('Build failed');
output.error(
`Check your logs at ${now.url}/_logs or run ${code(
`now logs ${now.url}`
`now logs ${now.url}`,
{
// Backticks are interpreted as part of the URL, causing CMD+Click
// behavior to fail in editors like VSCode.
backticks: false,
}
)}`
);
@@ -598,7 +691,7 @@ export default async function main(
deployment,
deployStamp,
!argv['--no-clipboard'],
quiet
isFile
);
}
@@ -646,6 +739,11 @@ function handleCreateDeployError(output, error) {
return 1;
}
if (dataPath === '.name') {
output.error(message);
return 1;
}
if (keyword === 'type') {
const prop = dataPath.substr(1, dataPath.length);

View File

@@ -1,4 +1,4 @@
import { resolve, basename, join } from 'path';
import { resolve, basename } from 'path';
import { eraseLines } from 'ansi-escapes';
// @ts-ignore
import { write as copy } from 'clipboardy';
@@ -70,7 +70,6 @@ import {
InvalidRegionOrDCForScale,
} from '../../util/errors';
import { SchemaValidationFailed } from '../../util/errors';
import readPackage from '../../util/read-package';
interface Env {
[name: string]: string | null | undefined;
@@ -213,43 +212,6 @@ const promptForEnvFields = async (list: string[]) => {
return answers;
};
async function canUseZeroConfig(cwd: string): Promise<boolean> {
try {
const pkg = await readPackage(join(cwd, 'package.json'));
if (!pkg || pkg instanceof Error) {
return false;
}
const deps = Object.assign({}, pkg.dependencies, pkg.devDependencies);
// We can only check for a few frontends,
// since can never be sure if APIs will work
// with zero-config
if (
deps.next ||
deps.nuxt ||
deps.gatsby ||
deps.hexo ||
deps.gridsome ||
deps.umi ||
deps.docusaurus ||
deps['@docusaurus/core'] ||
deps['preact-cli'] ||
deps['ember-cli'] ||
deps['@vue/cli-service'] ||
deps['@angular/cli'] ||
deps['polymer-cli'] ||
deps['sirv-cli'] ||
deps['react-scripts']
) {
return true;
}
} catch (_) {}
return false;
}
export default async function main(
ctx: any,
contextName: string,
@@ -890,7 +852,7 @@ async function sync({
const { url } = now;
const dcs =
deploymentType !== 'static' && deployment.scale
? chalk` ({bold ${Object.keys(deployment.scale).join(', ')})`
? ` (${ chalk.bold(Object.keys(deployment.scale).join(', ')) })`
: '';
if (isTTY) {

View File

@@ -1,10 +1,15 @@
import path from 'path';
import chalk from 'chalk';
import pkg from '../../../package.json';
import DevServer from '../../util/dev/server';
import parseListen from '../../util/dev/parse-listen';
import { Output } from '../../util/output';
import { NowContext } from '../../types';
import Client from '../../util/client';
import { getLinkedProject } from '../../util/projects/link';
import { getFrameworks } from '../../util/get-frameworks';
import { isSettingValue } from '../../util/is-setting-value';
import cmd from '../../util/output/cmd';
type Options = {
'--debug'?: boolean;
@@ -18,10 +23,62 @@ export default async function dev(
output: Output
) {
const [dir = '.'] = args;
const cwd = path.resolve(dir);
let cwd = path.resolve(dir);
const listen = parseListen(opts['--listen'] || '3000');
const debug = opts['--debug'] || false;
const devServer = new DevServer(cwd, { output, debug });
const client = new Client({
apiUrl: ctx.apiUrl,
token: ctx.authConfig.token,
currentTeam: ctx.config.currentTeam,
debug,
});
// retrieve dev command
const [link, frameworks] = await Promise.all([
getLinkedProject(output, client, cwd),
getFrameworks(),
]);
if (link.status === 'error') {
return link.exitCode;
}
if (link.status === 'not_linked' && !process.env.__NOW_SKIP_DEV_COMMAND) {
output.print(
`${chalk.red(
'Error!'
)} Your codebase isnt linked to a project on ZEIT Now. Run ${cmd(
'now'
)} to link it.\n`
);
return 1;
}
let devCommand: undefined | string;
if (link.status === 'linked') {
const { project } = link;
if (project.devCommand) {
devCommand = project.devCommand;
} else if (project.framework) {
const framework = frameworks.find(f => f.slug === project.framework);
if (framework) {
const defaults = framework.settings.devCommand;
if (isSettingValue(defaults)) {
devCommand = defaults.value;
}
}
}
if (project.rootDirectory) {
cwd = path.join(cwd, project.rootDirectory);
}
}
const devServer = new DevServer(cwd, { output, debug, devCommand });
process.once('SIGINT', () => devServer.stop());

View File

@@ -13,7 +13,6 @@ import param from '../../util/output/param';
import promptBool from '../../util/input/prompt-bool';
import purchaseDomain from '../../util/domains/purchase-domain';
import stamp from '../../util/output/stamp';
import wait from '../../util/output/wait';
type Options = {
'--debug': boolean;
@@ -27,7 +26,7 @@ export default async function buy(
) {
const {
authConfig: { token },
config
config,
} = ctx;
const { currentTeam } = config;
const { apiUrl } = ctx;
@@ -100,7 +99,7 @@ export default async function buy(
let buyResult;
const purchaseStamp = stamp();
const stopPurchaseSpinner = wait('Purchasing');
const stopPurchaseSpinner = output.spinner('Purchasing');
try {
buyResult = await purchaseDomain(client, domainName, price);

View File

@@ -9,7 +9,6 @@ import listInput from '../../util/input/list';
import listItem from '../../util/output/list-item';
import promptBool from '../../util/input/prompt-bool';
import toHumanPath from '../../util/humanize-path';
import wait from '../../util/output/wait';
import { Output } from '../../util/output';
import { NowContext } from '../../types';
import success from '../../util/output/success';
@@ -24,10 +23,10 @@ type Options = {
};
type Example = {
name: string,
visible: boolean,
suggestions: string[]
}
name: string;
visible: boolean;
suggestions: string[];
};
const EXAMPLE_API = 'https://now-example-files.zeit.sh';
@@ -40,7 +39,7 @@ export default async function init(
const [name, dir] = args;
const force = opts['-f'] || opts['--force'];
const examples = await fetchExampleList();
const examples = await fetchExampleList(output);
if (!examples) {
throw new Error(`Could not fetch example list.`);
@@ -56,22 +55,22 @@ export default async function init(
return 0;
}
return extractExample(chosen, dir, force);
return extractExample(output, chosen, dir, force);
}
if (exampleList.includes(name)) {
return extractExample(name, dir, force);
return extractExample(output, name, dir, force);
}
const oldExample = examples.find(x => !x.visible && x.name === name);
if (oldExample) {
return extractExample(name, dir, force, 'v1');
return extractExample(output, name, dir, force, 'v1');
}
const found = await guess(exampleList, name);
if (typeof found === 'string') {
return extractExample(found, dir, force);
return extractExample(output, found, dir, force);
}
console.log(info('No changes made.'));
@@ -81,8 +80,8 @@ export default async function init(
/**
* Fetch example list json
*/
async function fetchExampleList() {
const stopSpinner = wait('Fetching examples');
async function fetchExampleList(output: Output) {
const stopSpinner = output.spinner('Fetching examples');
const url = `${EXAMPLE_API}/v2/list.json`;
try {
@@ -93,7 +92,7 @@ async function fetchExampleList() {
throw new Error(`Failed fetching list.json (${resp.statusText}).`);
}
return await resp.json() as Example[];
return (await resp.json()) as Example[];
} catch (e) {
stopSpinner();
}
@@ -106,22 +105,28 @@ async function chooseFromDropdown(message: string, exampleList: string[]) {
const choices = exampleList.map(name => ({
name,
value: name,
short: name
short: name,
}));
return listInput({
message,
separator: false,
choices
choices,
});
}
/**
* Extract example to directory
*/
async function extractExample(name: string, dir: string, force?: boolean, ver: string = 'v2') {
async function extractExample(
output: Output,
name: string,
dir: string,
force?: boolean,
ver: string = 'v2'
) {
const folder = prepareFolder(process.cwd(), dir || name, force);
const stopSpinner = wait(`Fetching ${name}`);
const stopSpinner = output.spinner(`Fetching ${name}`);
const url = `${EXAMPLE_API}/${ver}/download/${name}.tar.gz`;

View File

@@ -9,7 +9,6 @@ import createOutput from '../util/output';
import Now from '../util';
import logo from '../util/output/logo';
import elapsed from '../util/output/elapsed.ts';
import wait from '../util/output/wait';
import { handleError } from '../util/error';
import strlen from '../util/strlen.ts';
import Client from '../util/client.ts';
@@ -79,13 +78,16 @@ export default async function main(ctx) {
return 1;
}
const { authConfig: { token }, config } = ctx;
const {
authConfig: { token },
config,
} = ctx;
const { currentTeam } = config;
const client = new Client({
apiUrl,
token,
currentTeam,
debug: debugEnabled
debug: debugEnabled,
});
let contextName = null;
@@ -104,7 +106,7 @@ export default async function main(ctx) {
// resolve the deployment, since we might have been given an alias
const depFetchStart = Date.now();
const cancelWait = wait(
const cancelWait = output.spinner(
`Fetching deployment "${id}" in ${chalk.bold(contextName)}`
);
@@ -140,7 +142,7 @@ export default async function main(ctx) {
limits,
version,
routes,
readyState
readyState,
} = deployment;
const isBuilds = version === 2;
@@ -159,7 +161,7 @@ export default async function main(ctx) {
)}/events?types=event`
)
),
isBuilds ? now.fetch(buildsUrl) : { builds: [] }
isBuilds ? now.fetch(buildsUrl) : { builds: [] },
]);
cancelWait();
@@ -174,7 +176,9 @@ export default async function main(ctx) {
print(` ${chalk.cyan('version')}\t${version}\n`);
print(` ${chalk.cyan('id')}\t\t${finalId}\n`);
print(` ${chalk.cyan('name')}\t${name}\n`);
print(` ${chalk.cyan('readyState')}\t${stateString(state || readyState)}\n`);
print(
` ${chalk.cyan('readyState')}\t${stateString(state || readyState)}\n`
);
if (!isBuilds) {
print(` ${chalk.cyan('type')}\t${type}\n`);
}
@@ -255,7 +259,7 @@ export default async function main(ctx) {
`${table(t, {
align: ['l', 'c', 'c', 'c'],
hsep: ' '.repeat(8),
stringLength: strlen
stringLength: strlen,
}).replace(/^(.*)/gm, ' $1')}\n`
);
print('\n');
@@ -269,9 +273,9 @@ export default async function main(ctx) {
events.forEach(data => {
if (!data.event) return; // keepalive
print(
` ${chalk.gray(
new Date(data.created).toISOString()
)} ${data.event} ${getEventMetadata(data)}\n`
` ${chalk.gray(new Date(data.created).toISOString())} ${
data.event
} ${getEventMetadata(data)}\n`
);
});
print('\n');

View File

@@ -8,10 +8,7 @@ import chalk from 'chalk';
import ua from '../util/ua.ts';
import getArgs from '../util/get-args';
import error from '../util/output/error';
import aborted from '../util/output/aborted';
import wait from '../util/output/wait';
import highlight from '../util/output/highlight';
import info from '../util/output/info';
import ok from '../util/output/ok';
import cmd from '../util/output/cmd.ts';
import param from '../util/output/param.ts';
@@ -24,7 +21,8 @@ import hp from '../util/humanize-path';
import logo from '../util/output/logo';
import exit from '../util/exit';
import createOutput from '../util/output';
import executeLogin from '../util/login/login.ts'
import executeLogin from '../util/login/login.ts';
import { prependEmoji, emoji } from '../util/emoji';
const debug = debugFactory('now:sh:login');
@@ -57,7 +55,7 @@ const help = () => {
const verify = async ({ apiUrl, email, verificationToken }) => {
const query = {
email,
token: verificationToken
token: verificationToken,
};
debug('GET /now/registration/verify');
@@ -68,7 +66,7 @@ const verify = async ({ apiUrl, email, verificationToken }) => {
res = await fetch(
`${apiUrl}/now/registration/verify?${stringifyQuery(query)}`,
{
headers: { 'User-Agent': ua }
headers: { 'User-Agent': ua },
}
);
} catch (err) {
@@ -105,12 +103,12 @@ const readEmail = async () => {
let email;
try {
email = await promptEmail({ start: info('Enter your email: ') });
email = await promptEmail({ start: `Enter your email: ` });
} catch (err) {
console.log(); // \n
if (err.message === 'User abort') {
throw new Error(aborted('No changes made.'));
throw new Error(`${chalk.red('Aborted!')} No changes made`);
}
if (err.message === 'stdin lacks setRawMode support') {
@@ -192,7 +190,7 @@ const login = async ctx => {
let verificationToken;
let securityCode;
stopSpinner = wait('Sending you an email');
stopSpinner = output.spinner('Sending you an email');
try {
const data = await executeLogin(apiUrl, email);
@@ -200,7 +198,7 @@ const login = async ctx => {
securityCode = data.securityCode;
} catch (err) {
stopSpinner();
console.log(error(err.message))
console.log(error(err.message));
return 1;
}
@@ -209,18 +207,15 @@ const login = async ctx => {
// Clear up `Sending email` success message
process.stdout.write(eraseLines(possibleAddress ? 1 : 2));
console.log(
info(
`We sent an email to ${highlight(
email
)}. Please follow the steps provided`,
` inside it and make sure the security code matches ${highlight(
securityCode
)}.`
)
output.print(
`We sent an email to ${highlight(
email
)}. Please follow the steps provided inside it and make sure the security code matches ${highlight(
securityCode
)}.\n`
);
stopSpinner = wait('Waiting for your confirmation');
stopSpinner = output.spinner('Waiting for your confirmation');
let token;
@@ -256,8 +251,15 @@ const login = async ctx => {
output.debug(`Saved credentials in "${hp(getNowDir())}"`);
console.log(
`${chalk.cyan('> Congratulations!')} ` +
`You are now logged in. In order to deploy something, run ${cmd('now')}.`
`${chalk.cyan('Congratulations!')} ` +
`You are now logged in. In order to deploy something, run ${cmd('now')}.`
);
output.print(
`${prependEmoji(
`Connect your Git Repositories to deploy every branch push automatically (https://zeit.ink/1X).`,
emoji('tip')
)}\n`
);
return ctx;

View File

@@ -6,7 +6,6 @@ import logo from '../util/output/logo';
import elapsed from '../util/output/elapsed.ts';
import { maybeURL, normalizeURL, parseInstanceURL } from '../util/url';
import printEvents from '../util/events';
import wait from '../util/output/wait';
import Client from '../util/client.ts';
import getScope from '../util/get-scope.ts';
@@ -165,7 +164,7 @@ export default async function main(ctx) {
const id = deploymentIdOrURL;
const depFetchStart = Date.now();
const cancelWait = wait(
const cancelWait = output.spinner(
`Fetching deployment "${id}" in ${chalk.bold(contextName)}`
);
@@ -287,12 +286,12 @@ function printLogShort(log) {
data = JSON.stringify(obj, null, 2);
} else {
data = (log.text || '')
.replace(/\n$/, '')
.replace(/^\n/, '')
// eslint-disable-next-line no-control-regex
.replace(/\x1b\[1000D/g, '')
.replace(/\x1b\[0K/g, '')
.replace(/\x1b\[1A/g, '');
.replace(/\n$/, '')
.replace(/^\n/, '')
// eslint-disable-next-line no-control-regex
.replace(/\x1b\[1000D/g, '')
.replace(/\x1b\[0K/g, '')
.replace(/\x1b\[1A/g, '');
if (/warning/i.test(data)) {
data = chalk.yellow(data);
} else if (log.type === 'stderr') {

View File

@@ -6,7 +6,6 @@ import table from 'text-table';
import Now from '../util';
import getAliases from '../util/alias/get-aliases';
import createOutput from '../util/output';
import wait from '../util/output/wait';
import logo from '../util/output/logo';
import cmd from '../util/output/cmd.ts';
import elapsed from '../util/output/elapsed.ts';
@@ -132,7 +131,7 @@ export default async function main(ctx) {
throw err;
}
const cancelWait = wait(
const cancelWait = output.spinner(
`Fetching deployment(s) ${ids
.map(id => `"${id}"`)
.join(' ')} in ${chalk.bold(contextName)}`

View File

@@ -11,6 +11,7 @@ import logo from '../util/output/logo';
import Client from '../util/client.ts';
import getScope from '../util/get-scope.ts';
import createOutput from '../util/output';
import confirm from '../util/input/confirm';
const help = () => {
console.log(`
@@ -144,7 +145,7 @@ async function run({ output, token, contextName, currentTeam }) {
const elapsed = ms(new Date() - start);
console.log(
`> ${plural('secret', list.length, true)} found under ${chalk.bold(
`${plural('secret', list.length, true)} found under ${chalk.bold(
contextName
)} ${chalk.gray(`[${elapsed}]`)}`
);
@@ -189,22 +190,29 @@ async function run({ output, token, contextName, currentTeam }) {
const theSecret = list.find(secret => secret.name === args[0]);
if (theSecret) {
const yes = argv.yes || (await readConfirmation(theSecret));
const yes =
argv.yes || (await readConfirmation(output, theSecret, contextName));
if (!yes) {
console.error(error('User abort'));
output.print(`Aborted. Secret not deleted.\n`);
return exit(0);
}
} else {
console.error(error(`No secret found by name "${args[0]}"`));
console.error(
error(
`No secret found by name "${args[0]}" under ${chalk.bold(
contextName
)}`
)
);
return exit(1);
}
const secret = await secrets.rm(args[0]);
const elapsed = ms(new Date() - start);
console.log(
`${chalk.cyan('> Success!')} Secret ${chalk.bold(
`${chalk.cyan('Success!')} Secret ${chalk.bold(
secret.name
)} removed ${chalk.gray(`[${elapsed}]`)}`
)} under ${chalk.bold(contextName)} removed ${chalk.gray(`[${elapsed}]`)}`
);
return secrets.close();
}
@@ -223,9 +231,11 @@ async function run({ output, token, contextName, currentTeam }) {
const secret = await secrets.rename(args[0], args[1]);
const elapsed = ms(new Date() - start);
console.log(
`${chalk.cyan('> Success!')} Secret ${chalk.bold(
`${chalk.cyan('Success!')} Secret ${chalk.bold(
secret.oldName
)} renamed to ${chalk.bold(args[1])} ${chalk.gray(`[${elapsed}]`)}`
)} renamed to ${chalk.bold(args[1])} under ${chalk.bold(
contextName
)} ${chalk.gray(`[${elapsed}]`)}`
);
return secrets.close();
}
@@ -243,7 +253,7 @@ async function run({ output, token, contextName, currentTeam }) {
if (args.length > 2) {
const example = chalk.cyan(`$ now secret add -- "${args[0]}"`);
console.log(
`> If your secret has spaces or starts with '-', make sure to terminate command options with double dash and wrap it in quotes. Example: \n ${example} `
`If your secret has spaces or starts with '-', make sure to terminate command options with double dash and wrap it in quotes. Example: \n ${example} `
);
}
@@ -259,9 +269,9 @@ async function run({ output, token, contextName, currentTeam }) {
}
console.log(
`${chalk.cyan('> Success!')} Secret ${chalk.bold(
`${chalk.cyan('Success!')} Secret ${chalk.bold(
name.toLowerCase()
)} added (${chalk.bold(contextName)}) ${chalk.gray(`[${elapsed}]`)}`
)} added under ${chalk.bold(contextName)} ${chalk.gray(`[${elapsed}]`)}`
);
return secrets.close();
}
@@ -278,33 +288,19 @@ process.on('uncaughtException', err => {
exit(1);
});
function readConfirmation(secret) {
return new Promise(resolve => {
const time = chalk.gray(`${ms(new Date() - new Date(secret.created))} ago`);
const tbl = table([[chalk.bold(secret.name), time]], {
align: ['r', 'l'],
hsep: ' '.repeat(6),
});
process.stdout.write(
'> The following secret will be removed permanently\n'
);
process.stdout.write(` ${tbl}\n`);
process.stdout.write(
`${chalk.bold.red('> Are you sure?')} ${chalk.gray('[y/N] ')}`
);
process.stdin
.on('data', d => {
process.stdin.pause();
resolve(
d
.toString()
.trim()
.toLowerCase() === 'y'
);
})
.resume();
async function readConfirmation(output, secret, contextName) {
const time = chalk.gray(`${ms(new Date() - new Date(secret.created))} ago`);
const tbl = table([[chalk.bold(secret.name), time]], {
align: ['r', 'l'],
hsep: ' '.repeat(6),
});
output.print(
`The following secret will be removed permanently from ${chalk.bold(
contextName
)}\n`
);
output.print(` ${tbl}\n`);
return confirm(`${chalk.bold.red('Are you sure?')}`, false);
}

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