Skip to content

Commit

Permalink
Merge branch 'master' of github.com:gatsbyjs/gatsby into typescript-g…
Browse files Browse the repository at this point in the history
…atsby-redux-reducers-components
  • Loading branch information
Kornil committed May 15, 2020
2 parents b4196cf + 3242894 commit 8d42803
Show file tree
Hide file tree
Showing 198 changed files with 2,775 additions and 1,287 deletions.
3 changes: 2 additions & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,9 @@ aliases:
- <<: *attach_to_bootstrap
- run: yarn list react
- run:
command: node --max-old-space-size=2048 ./node_modules/.bin/jest -w 1 --ci --reporters=jest-junit
command: node --max-old-space-size=2048 ./node_modules/.bin/jest -w 1 --ci
environment:
GENERATE_JEST_REPORT: true
JEST_JUNIT_OUTPUT_DIR: ./test-results/jest-node/
JEST_JUNIT_OUTPUT_NAME: results.xml
- store_test_results:
Expand Down
2 changes: 1 addition & 1 deletion docs/blog/100days/free-hosting/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ Bonus: Try deploying your site to the free tier of multiple services to see firs

For your git repo, you can use GitHub, GitLab, Bitbucket, or many similar services.

And for your build tool and CDN we see many people have success with [AWS Amplify](/docs/deploying-to-aws-amplify/), [Netlify](/docs/deploying-to-netlify/), and [ZEIT Now](/docs/deploying-to-zeit-now/). Our documentation has step-by-step tutorials for those services, [and others](/docs/deploying-and-hosting/).
And for your build tool and CDN we see many people have success with [AWS Amplify](/docs/deploying-to-aws-amplify/), [Netlify](/docs/deploying-to-netlify/), and [Vercel](/docs/deploying-to-vercel). Our documentation has step-by-step tutorials for those services, [and others](/docs/deploying-and-hosting/).

### What to Do If You Need Help

Expand Down
30 changes: 15 additions & 15 deletions docs/blog/2019-01-01-publish-multiple-gatsby-sites/index.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
---
title: Publish Multiple Gatsby Sites in a Monorepo, Using Lerna, Travis & Now
title: Publish Multiple Gatsby Sites in a Monorepo, Using Lerna, Travis & Vercel
date: 2019-01-01
author: Andrico Karoulla
tags: ["apps", "testing", "deployment"]
Expand All @@ -10,7 +10,7 @@ excerpt: Learn how to create a balanced lasagna instead of a tangled mess of spa

### Foreword

This tutorial will take about two hours to complete. If you're unfamiliar with Lerna, Travis or Now, you may fall into a few traps, but it's all part of the learning process! I’ve included a troubleshooting section at the end of the article for common problems, so refer to it at any time.
This tutorial will take about two hours to complete. If you're unfamiliar with Lerna, Travis or Vercel, you may fall into a few traps, but it's all part of the learning process! I’ve included a troubleshooting section at the end of the article for common problems, so refer to it at any time.

### Introduction

Expand Down Expand Up @@ -365,7 +365,7 @@ You can stop the tutorial now and you’ll have a working knowedge of when, how

Let’s take a second to reflect on where we are right now. We’ve managed to start with a single application with two discrete sections and split them apart in a monorepo. This allows us to _separate the concerns_ and share reusable components.

There are two parts to this section, our Continuous Integration (CI) pipeline and the site’s deployment. Our CI pipeline will be used to automate a series of checks to ensure our tests pass and our build compiles. If either of these, or any part of the pipeline, fails then our site won’t deploy. The second part is how we deal with a successful build, and that’s deployment! If everything passes, our site will deploy using Now, where it will be hosted for the world to see on the interwebs.
There are two parts to this section, our Continuous Integration (CI) pipeline and the site’s deployment. Our CI pipeline will be used to automate a series of checks to ensure our tests pass and our build compiles. If either of these, or any part of the pipeline, fails then our site won’t deploy. The second part is how we deal with a successful build, and that’s deployment! If everything passes, our site will deploy using Vercel, where it will be hosted for the world to see on the interwebs.

To use Travis we’ll first need to create an account and add the GitHub repo we’ve been pushing to. And like with every other tool we’ve used, the best way to get started with Travis is by reading [Travis’ getting started page](https://docs.travis-ci.com/user/getting-started/). The getting started page also runs through adding your GitHub repo which can be done via the main page. Click the ‘+’ and on your profile page click ‘Manage repositories in GitHub’. Choose the repo that you’ve been using and you should be set up.

Expand Down Expand Up @@ -459,13 +459,13 @@ script:

Hopefully what I’ve said makes more sense with the code in front of us. The `script` pipeline runs for each step we’ve included in the `matrix`. We’ve also added another step to the `script` section, this is doing nothing more than moving to the directory of the current package. Push the changes again to your repo and open Travis to see your pipeline running. You should now be seeing two build jobs running simultaneously, which means our matrix is working. If everything passes, we’ll move on to deploying our application.

### Now
### Vercel

Now is a tool created by ZEIT that makes the process of deploying Node applications simple. Now has recently released updates to the way they deploy static websites. Fortunately our Gatsby packages build to static sites, so it’s a win for us.
Vercel is a tool created by VERCEL that makes the process of deploying Node applications simple. Vercel has recently released updates to the way they deploy static websites. Fortunately our Gatsby packages build to static sites, so it’s a win for us.

If you haven’t used Now before, then go-ahead and [get started](https://zeit.co/now#features). This will install the `now-cli` and get a free account created, things we need for the tutorial. The getting started page also has a brief FAQs section that’s well worth reading.
If you haven’t used Vercel before, then go-ahead and [get started](https://vercel.com/home#features). This will install the `Vercel CLI` and get a free account created, things we need for the tutorial. The getting started page also has a brief FAQs section that’s well worth reading.

Travis-CI isn’t permitted to deploy to your Now account by default, and requires a token. You can create a token via the Account Settings page on the Now website. Once you’re there click the tokens tab and create a new token. Copy it to your clipboard, as we’ll be adding to the list of variables that Travis uses in our pipelines. Go to your lerna-monorepo repository in Travis and from the ‘More options’ drop down, click ‘settings’. When you’re here, you’ll see a section called ‘environment variables’. Create a new variable called `NOW_TOKEN` and paste your Now public key as the value. We can now reference the key from within our `.travis.yml` file.
Travis-CI isn’t permitted to deploy to your Vercel account by default, and requires a token. You can create a token via the Account Settings page on the Vercel website. Once you’re there click the tokens tab and create a new token. Copy it to your clipboard, as we’ll be adding to the list of variables that Travis uses in our pipelines. Go to your lerna-monorepo repository in Travis and from the ‘More options’ drop down, click ‘settings’. When you’re here, you’ll see a section called ‘environment variables’. Create a new variable called `VERCEL_TOKEN` and paste your Vercel public key as the value. We can now reference the key from within our `.travis.yml` file.

We’ll add the final part of our pipeline now, which deals with deployment. Make sure your `.travis.yml` file looks like the following, and we’ll run through the additions.

Expand Down Expand Up @@ -494,7 +494,7 @@ script:
deploy:
provider: script
script: now public --token $NOW_TOKEN
script: now public --token $VERCEL_TOKEN
skip_cleanup: true
app: $PACKAGE_NAME
```
Expand All @@ -506,7 +506,7 @@ Note that we’ve added some additional environment variables to our matrix so a
- skip_cleanup — we don’t want Travis to get rid of any files made during the build. We created the ‘public’ folder when running the build, so we don’t want Travis to get rid of it.
- app — specifies the name of the application we’re deploying,

We have to do add a little bit of configuration on our side to ensure that Now hosts our sites correctly. The config comes in the form of a `now.json` file, which outlines the options we want Now to use when deploying our site. Go into the directory for our blog packages and create a `now.json` file. We want to let Now know that we’re deploying a static site, the entry directory to the static site, and what alias we want to assign our site. Put this inside your `now.json` file.
We have to do add a little bit of configuration on our side to ensure that Vercel hosts our sites correctly. The config comes in the form of a `now.json` file, which outlines the options we want Vercel to use when deploying our site. Go into the directory for our blog packages and create a `now.json` file. We want to let Vercel know that we’re deploying a static site, the entry directory to the static site, and what alias we want to assign our site. Put this inside your `now.json` file.

```json:title=now.json
{
Expand All @@ -520,16 +520,16 @@ We have to do add a little bit of configuration on our side to ensure that Now h
}
```

Note: `public: true` needs to be specified since you’ll most likely have a free Now account. Having a publicly facing site is one of the restrictions of the free tier. The entry file to our static site is also called `public` so don’t conflate the two.
Note: `public: true` needs to be specified since you’ll most likely have a free Vercel account. Having a publicly facing site is one of the restrictions of the free tier. The entry file to our static site is also called `public` so don’t conflate the two.

Push these changes to your repo to kick off your build pipeline. If everything was successful then your build will have passed and your site will have deployed. Go to Travis, open up your blog build so you have access to the logs. Scroll right to the bottom to where it says ‘deploying application’ and uncollapse the section. This’ll be the URL that Now deployed your site to. It should look something like `https://buildsjdoe383jd.now.sh`. Copy that url and go back to your command line. Run the following command:
Push these changes to your repo to kick off your build pipeline. If everything was successful then your build will have passed and your site will have deployed. Go to Travis, open up your blog build so you have access to the logs. Scroll right to the bottom to where it says ‘deploying application’ and uncollapse the section. This’ll be the URL that Vercel deployed your site to. It should look something like `https://buildsjdoe383jd.vercel.app`. Copy that url and go back to your command line. Run the following command:

`now alias <your randomly generated URL> <your chosen alias>`
I chose ‘lerna-monorepo-blog’ as my alias, so that one won’t be available for you to use, so choose your own. When you’ve run the command, there will be feedback saying that the alias was successfully created. If not, then it’s likely the command was written incorrectly or the alias is already in use by someone else. Once you’ve added an alias successfully for the blog, do the same for your shop package.

Even if you push everything forward now the site’s navigation will still be broken. The very last thing we need to do is add our alias URL as an environment variables in our `.env.production` file. In your blog package’s `.env.production` go ahead and add the following:

`BLOG_URL=https://<your chosen alias>.now.sh/`
`BLOG_URL=https://<your chosen alias>.vercel.app/`

Do the same for your shop url, commit and push. Congrats!

Expand Down Expand Up @@ -561,12 +561,12 @@ My suggestion would be to have the package level react dependency the latest ver

Running the pipeline for your application:

If your CI pipeline isn’t deploying your site correctly, it can be difficult to distinguish whether or not it’s an issue with Travis or an issue with Now. If you can navigate to one of your package directory and run now, and everything's successful, then it’s likely an issue with your `.travis.yml` file or the way in which your defining your environment variables in Travis. Go over that section one more time to make sure you’ve got it all written as it should be.
If your CI pipeline isn’t deploying your site correctly, it can be difficult to distinguish whether or not it’s an issue with Travis or an issue with Vercel. If you can navigate to one of your package directory and run now, and everything's successful, then it’s likely an issue with your `.travis.yml` file or the way in which your defining your environment variables in Travis. Go over that section one more time to make sure you’ve got it all written as it should be.

Deploying your application:

If running the now command in your package throws an error, then make sure you’re logged in to now via the CLI. You can do this via now login. Make sure that your `now.json` file points to the correct output of yarn build. It may be your version of Gatsby doesn’t create a build directory called `public` but instead `dist` or `build`.
If running the now command in your package throws an error, then make sure you’re logged in to Vercel via the CLI. You can do this via Vercel login. Make sure that your `now.json` file points to the correct output of yarn build. It may be your version of Gatsby doesn’t create a build directory called `public` but instead `dist` or `build`.

Viewing your live application:

Chances are that you might need to deploy your site more than once before everything works, lord knows I did when writing this application. One thing that tripped me up was client-side caching. Which is something that Now does out of the box. It just means that even if you’ve deployed a new version of the site, you might be viewing an older, cached version. If this is the case, open the Chrome/browser dev tools, right-click the reload symbol, and click ‘empty cache and hard reload’.
Chances are that you might need to deploy your site more than once before everything works, lord knows I did when writing this application. One thing that tripped me up was client-side caching. Which is something that Vercel does out of the box. It just means that even if you’ve deployed a new version of the site, you might be viewing an older, cached version. If this is the case, open the Chrome/browser dev tools, right-click the reload symbol, and click ‘empty cache and hard reload’.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,6 @@ Sanity already comes with a capable and easy to use image pipeline on a superfas

Gatsby has already set high standards for developer experience by striking a good balance between code and configuration. We have worked hard to make it as effortless as possible to use [Sanity.io](https://www.sanity.io) as a content backend with Gatsby, and we hope that you will enjoy building websites with this combo.

If you quickly want to get started with a full JAMstack combo, check out the [company website example](https://github.com/sanity-io/example-company-website-gatsby-sanity-combo) we put up. It features both a Studio configuration and a website template with projects, blog, people, and pages. With configuration files to put the website on either [Now](https://zeit.co) or [Netlify](https://netlify.com). You should be up in minutes.
If you quickly want to get started with a full JAMstack combo, check out the [company website example](https://github.com/sanity-io/example-company-website-gatsby-sanity-combo) we put up. It features both a Studio configuration and a website template with projects, blog, people, and pages. With configuration files to put the website on either [Vercel](https://vercel.com) or [Netlify](https://netlify.com). You should be up in minutes.

We're very excited to see whatever you do with it and welcome you to come with all your questions, feedback, and ideas in [our developer community](https://slack.sanity.io).
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ There is a small blog that does this very thing. They build the Firebase credent

Assuming a nation state is not trying to attack you, what are you options for better security? You need an API.

One great option is to check out Netlify. They will provide great static hosting and allow you to deploy serverless functions right along side your Gatsby site. They are not the only ones: Azure, Google, Amazon, Zeit.co, and others all have API solutions.
One great option is to check out Netlify. They will provide great static hosting and allow you to deploy serverless functions right along side your Gatsby site. They are not the only ones: Azure, Google, Amazon, Vercel, and others all have API solutions.

What does this API allow? First, you can secure your database. Any API keys can be secured on your serverless...server 😭. The point is, they will be secure. But what does this gain you? After all, instead of pillaging your database directly you have given them an API through which to pillage.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ The flexibility of Kentico Cloud means there are many ways to achieve the same g

Our first step is to determine how we are going to identify cultures or languages from the frontend of the site. As Kentico Cloud is purely a content hub, there’s not the same set of localization web parts and widgets that you might get from a product like Kentico EMS. We need an alternative to pick up that culture code.

There are a few options here. You could be using a simple language switcher control on your site or application. Or, it might be as simple as deriving it from the URL e.g. _www.mysite.com/en-gb/about-us_ or _www.mysite.com/about-us?lang=en-gb_.
There are a few options here. You could be using a simple language switcher control on your site or application. Or, it might be as simple as deriving it from the URL e.g. `www.mysite.com/en-gb/about-us` or `www.mysite.com/about-us?lang=en-gb`.

Whichever route you’ve taken, once you know the culture code then you can get any ‘key’ and ‘value’ pairs for the required culture.

Expand Down
2 changes: 1 addition & 1 deletion docs/blog/2019-11-14-announcing-gatsby-cloud/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ https://youtu.be/AmkI2iH6c40

We'll soon be shipping a fast build service that will dramatically speed up your Gatsby builds. It will provide feedback while you develop and deploy your code and content changes to your hosting platform.

Gatsby Cloud Builds works in similar ways to build services like Heroku, Netlify, Zeit, and others that integrate with GitHub and other services to automatically build and deploy your site when you make changes. We integrate with a number of different CDNs such as Netlify, Fastly, and Firebase as well as the major cloud providers so you can host your site wherever you'd like.
Gatsby Cloud Builds works in similar ways to build services like Heroku, Netlify, Vercel, and others that integrate with GitHub and other services to automatically build and deploy your site when you make changes. We integrate with a number of different CDNs such as Netlify, Fastly, and Firebase as well as the major cloud providers so you can host your site wherever you'd like.

We're tackling this problem in our Gatsby Cloud Builds service through two strategies that take advantage of the special nature of cloud computing.

Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 8d42803

Please sign in to comment.