Skip to content

Commit

Permalink
Reference guide on how to upgrade Gatsby and its dependencies for min…
Browse files Browse the repository at this point in the history
…or and patch releases (#17790)

* resolves #14598

Adds a reference guide on how to upgrade Gatsby and its dependencies

* Fixed typos and added related content

* Fixed additional typos

* Fixed additional typos, one with the name of the file, added links for the doc-links.yaml file, escaped < and > characters in markdown thata were causing some errors

* Updated title based on @marcysutton suggestions

Co-Authored-By: Marcy Sutton <marcy@gatsbyjs.com>

* Solves suggested changes such as modifying links for relative urls, removing yarn instructions and alignments to Gatsby style guide

* Apply additional suggestions

Co-Authored-By: Marcy Sutton <marcy@gatsbyjs.com>
  • Loading branch information
Uriel Hernández and Marcy Sutton committed Sep 25, 2019
1 parent eb50ab5 commit 2f9174e
Show file tree
Hide file tree
Showing 2 changed files with 122 additions and 0 deletions.
119 changes: 119 additions & 0 deletions docs/docs/upgrade-gatsby-and-dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
---
title: Upgrade for Minor or Patch Releases
---

To keep up with the latest bug fixes, security patches, and minor releases from both Gatsby and its dependencies, you should upgrade often to the latest version of each one.

## Semantic versioning

As many other packages, Gatsby uses [semantic versioning](https://semver.org/) to tag new versions and indicate what kind of changes are introduced in every new release.

This guide is meant to teach you how to upgrade Gatsby for minor or patch releases. For major changes you can refer to the [Release and Migrations](/docs/releases-and-migration/) reference guide overview for the corresponding guide to upgrade.

## Why you should upgrade Gatsby and its dependencies

Every new version of every package comes with improvements on multiple categories from performance, accessibility, security, bug fixes, and more, so it is important to upgrade both Gatsby and its dependencies to get the latest improvements in every one of these categories.

Upgrading your dependencies often on minor or patch releases also helps you to make major upgrades easier and to identify soon-to-be-deprecated functionality or APIs.

## How to identify possible upgrades

To start, you can run the `outdated` command to identify new releases for all your dependencies.

```shell
npm outdated
```

This will output a table indicating which packages have new versions available and what is the latest version for each one.

```
Package Current Wanted Latest Location
gatsby 2.15.13 2.15.13 2.15.20
```

## Configure your dependencies for upgrades

Depending on whether you want to update Gatsby and its dependencies for minor or patch releases you need to modify your `package.json` accordingly.

If you only want to update **for patch releases**, you can add a tilde (`~`) before the version of your package:

```json:title=package.json
"dependencies"{
"gatsby": "~2.15.13",
}
```

**For both patch and minor updates**, add a caret (`^`) before the version of your package:

```json:title=package.json
"dependencies"{
"gatsby": "^2.15.13",
}
```

For major updates follow up with the corresponding guide from the [Release and Migrations](/docs/releases-and-migration/) reference guide overview.

If you are updating Gatsby, you'll likely also need to update Gatsby related plugins, you can identify them by their names starting with `gatsby-`. This only applies to plugins managed in the [gatsbyjs/gatsby](https://github.com/gatsbyjs/gatsby) repo; for community plugins check beforehand if there is a new version available for upgrading.

## Updating all your dependencies at once

After adding the corresponding annotations into your `package.json` file, you can run the update command:

```shell
npm update
```

This will upgrade all your packages to the latest [wanted version](https://docs.npmjs.com/cli/outdated), such as the latest patch, minor, or major update depending on your annotations in `package.json`.

## Upgrade individual dependencies

You can also update one package at the time with the `install` command in npm, alongside the version that you want to install:

```shell
npm install <package-name>@<version> --save
```

You can specify the version you want to install or upgrade to, in the following formats:

- A specific version after the `@`
- An annotated version with `*`,`^`,`~` to indicate that you want the latest major, minor or patch release respectively.
- Use an `x` instead of a number to indicate that you want the latest major (`x`), minor (`<major>.x`) or patch release (`<major>.<minor>.x`). For example, to install the latest patch release for a given major and minor version: `npm install package-name@2.1.x --save`

For major upgrades, remember to follow up with the corresponding guide from the [Release and Migrations](/docs/releases-and-migration/) reference guide overview.

## Upgrade Interactively

You can manually select which dependencies you want to update through the [npm-check](https://www.npmjs.com/package/npm-check) module. To do that, start by installing the module:

```shell
npm install npm-check --save-dev
```

Then add the corresponding script to your package.json file:

```json:title=package.json
{
"scripts": {
"upgrade-interactive": "npm-check --update"
}
}
```

And finally run the recently added command:

```shell
npm run upgrade-interactive
```

## Troubleshooting

Aside from some specific cases, such as [Gatsby's dropping of support for Node 6](/blog/2019-06-18-dropping-support-for-node-6/), upgrading for minor or patch releases should not require you to make changes to your code. It is recommended to run your suite of tests (in case you have one) after upgrading Gatsby or its dependencies.

In case you get stuck in dependencies conflicts, you can use the [npm-force-resolutinos package](https://www.npmjs.com/package/npm-force-resolutions?activeTab=readme) on npm.

## Related content

Check out these related guides for major upgrades of Gatsby:

- [Migrating from v1 to v2](/docs/migrating-from-v1-to-v2/)
- [Migrating from v0 to v1](/docs/migrating-from-v0-to-v1/)
3 changes: 3 additions & 0 deletions www/src/data/sidebars/doc-links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -492,6 +492,9 @@
link: /docs/migrating-from-v1-to-v2/
- title: Migrating from v0 to v1
link: /docs/migrating-from-v0-to-v1/
- title: Upgrade for Minor or Patch Releases
link: /docs/upgrade-gatsby-and-dependencies/
breadcrumbTitle: Minor or Patch Releases
- title: Conceptual Guide
link: /docs/conceptual-guide/
items:
Expand Down

0 comments on commit 2f9174e

Please sign in to comment.