Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Gatsby Recipes): Initial release #22709

Merged
merged 132 commits into from
Apr 16, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
132 commits
Select commit Hold shift + click to select a range
64cc1de
Initial commit
KyleAMathews Apr 1, 2020
b0698d9
Cleanups
KyleAMathews Apr 1, 2020
36b5421
more cleanup
KyleAMathews Apr 1, 2020
461c7ee
Add missing remark-stringify dep (#22721)
johno Apr 1, 2020
50f4e0a
WIP
KyleAMathews Apr 1, 2020
716600c
WIP
KyleAMathews Apr 1, 2020
1fc328e
update TODOs
KyleAMathews Apr 1, 2020
27ac5e2
Prettier + enable Ink's experimental mode
KyleAMathews Apr 1, 2020
92b7c04
Don't need this anymore
KyleAMathews Apr 1, 2020
353ae8f
Support running local recipes e.g. gatsby recipes ./text.mdx
KyleAMathews Apr 1, 2020
3d49140
prettier again
KyleAMathews Apr 1, 2020
faa261f
Make config slightly more robust (#22743)
johno Apr 1, 2020
904e47d
Add support for devDependencies in NPMPackage resource
KyleAMathews Apr 2, 2020
cfdb1d2
Move package to new prop name
KyleAMathews Apr 2, 2020
c0e7b83
Update todos
KyleAMathews Apr 2, 2020
f044af7
add TODO
KyleAMathews Apr 2, 2020
66ff708
recipes: Improve providers (#22764)
johno Apr 2, 2020
d3d8a7b
Improve recipes providers (#22783)
KyleAMathews Apr 3, 2020
1be1b24
Support rendering more markdown
KyleAMathews Apr 3, 2020
f00c6a3
Support more markdown tags
KyleAMathews Apr 3, 2020
140190e
Tweak providers, add more thorough tests
johno Apr 3, 2020
9df2182
Clean up file after plan test
johno Apr 3, 2020
a5db934
recipes: Add initial package json resource (#22805)
johno Apr 3, 2020
14b9548
Copy recipes on change
KyleAMathews Apr 3, 2020
98054b4
improve stylings for h2/h3
KyleAMathews Apr 3, 2020
0f1c3f3
Refactor to use xstate
KyleAMathews Apr 4, 2020
587c0ab
Update TODOs
KyleAMathews Apr 4, 2020
23d483e
Improve parsing to handle basic template strings
johno Apr 4, 2020
905b7da
Improve parsing to handle basic template strings
johno Apr 4, 2020
1231d94
Chore(Recipes): Add recipes machine tests (#22823)
KyleAMathews Apr 4, 2020
2b33c6a
feat(recipes): Add resource schema/validation support (#22830)
KyleAMathews Apr 6, 2020
4f60b91
fix(recipes): Don't duplicate plugin configuration by default (#22861)
johno Apr 6, 2020
310abd2
feat(recipes): Generate graphql schema from resources (#22864)
johno Apr 6, 2020
e22d67e
feat(recipes): Create connection types for resources (#22876)
johno Apr 6, 2020
7f7ac96
Find the root directory of the Node.js project/npm package and use th…
KyleAMathews Apr 6, 2020
bb7a4c9
Fix
KyleAMathews Apr 7, 2020
07860d6
update tests
KyleAMathews Apr 7, 2020
c88c6a5
Write e2e tests for npm package scripts & add validate/all implementa…
KyleAMathews Apr 7, 2020
fca6807
Fix recipes (#22885)
mxstbr Apr 7, 2020
fb46a1e
Fix some more recipes (#22889)
mxstbr Apr 7, 2020
c8d103e
Fix more recipes stuff (#22891)
mxstbr Apr 7, 2020
04ac784
Fix typo
KyleAMathews Apr 7, 2020
6d390c5
feat(recipes): Implement shadowable files for themes (#22909)
johno Apr 7, 2020
a08e767
feat(recipes): iterate on recipe design (#22911)
KyleAMathews Apr 8, 2020
6b67046
Squashed master
KyleAMathews Apr 8, 2020
3b3f926
add todo
KyleAMathews Apr 8, 2020
b11808b
feat(recipes): Show recap of operations & show diff for changes to fi…
KyleAMathews Apr 9, 2020
eaa0535
Merge remote-tracking branch 'origin/master' into add-recipes
KyleAMathews Apr 9, 2020
f1d245b
Fix merge barf
KyleAMathews Apr 9, 2020
bbfa77f
Remove file that came in from bad merge
KyleAMathews Apr 9, 2020
c6de714
update todos
KyleAMathews Apr 9, 2020
bc369a0
Validate resources & improve file diffing (#22986)
KyleAMathews Apr 10, 2020
63604f3
Improve diffing & just run all resource operations serially
KyleAMathews Apr 10, 2020
64625e4
feat(recipes): Import recipes from urls and begin moving parsing to t…
johno Apr 10, 2020
2d191c4
update todos
KyleAMathews Apr 10, 2020
0be2a5d
Add support for file content on remote URLs
KyleAMathews Apr 10, 2020
793c3de
Add some basic docs & new emotion recipe
KyleAMathews Apr 10, 2020
de5e40c
Small updates to README
KyleAMathews Apr 10, 2020
0d0367d
small fixes
KyleAMathews Apr 10, 2020
c36ecee
fix
KyleAMathews Apr 10, 2020
ae665f0
More todos
KyleAMathews Apr 10, 2020
f4d5b2a
Cleanup comments
KyleAMathews Apr 10, 2020
7a0f08b
Add to docs about how to upgrade gatsby-cli
KyleAMathews Apr 10, 2020
22912c3
feat(recipes): Implement basic gitignore provider (#23003)
johno Apr 10, 2020
9a4695d
Move to jest-diff for faster diffing & more control
KyleAMathews Apr 10, 2020
19ad1d0
Update snapshots & use default jest-diff export as that handles any t…
KyleAMathews Apr 10, 2020
0401a13
Chalk thinks it shouldn't output color in a child process — fix that
KyleAMathews Apr 11, 2020
9a71723
tweak TODOs
KyleAMathews Apr 11, 2020
cf8603c
update todos
KyleAMathews Apr 12, 2020
abad6f3
update todos
KyleAMathews Apr 12, 2020
44aee1a
Move mdx source for recipes to their own directory
KyleAMathews Apr 13, 2020
5efb22f
Add Sass recipe
Apr 13, 2020
4f2e2df
Add recipe for setting up local gatsby-theme-blog
Apr 13, 2020
2a2802b
Add todo around bundling
KyleAMathews Apr 13, 2020
6add891
feat(recipes): Eliminate new lines from markdown (#23064)
KyleAMathews Apr 13, 2020
a47d188
feat(recipes): Implement shadow file resource and test it (#23063)
johno Apr 13, 2020
4823995
update todos
KyleAMathews Apr 13, 2020
f3a6f66
Update README.md
shannonbux Apr 13, 2020
eb2acd7
feat(recipes): detect if port is used and use a different one (#23076)
KyleAMathews Apr 13, 2020
e5c9a3d
feat(recipes): Tell people recipes is experimental & point them to th…
KyleAMathews Apr 13, 2020
3fd10b4
Update todo
KyleAMathews Apr 13, 2020
4d80e58
feat(recipes): Use the package manager client the user specifies in t…
KyleAMathews Apr 13, 2020
32edae3
feat(recipes): Improve error handling and validation for MDX files an…
johno Apr 13, 2020
c0d111c
chore(recipes): test File resouces with remote file content (#23084)
KyleAMathews Apr 13, 2020
40b0cdc
update todos
KyleAMathews Apr 13, 2020
2ef02d1
Update todos
johno Apr 14, 2020
27376b0
feat(Recipes): Show list of recipes when one isn't passed in (#23086)
KyleAMathews Apr 14, 2020
0e482a2
update todos & add layout recipe to list"
KyleAMathews Apr 14, 2020
69bac1b
feat(recipes): Move recipes to a standalone package (#23108)
johno Apr 14, 2020
a2c264c
Prettier color
KyleAMathews Apr 14, 2020
9acdd11
feat(recipes): Format gatsby-config changes with Prettier (#23112)
KyleAMathews Apr 14, 2020
2225382
Merge branch 'add-recipes' of github.com:gatsbyjs/gatsby into add-rec…
KyleAMathews Apr 14, 2020
197f639
Bigger changes (#23078)
shannonbux Apr 14, 2020
74350b0
feat(recipes): Add more recipes (#23119)
KyleAMathews Apr 14, 2020
0ca5abb
Fix name of <GatsbyShadowFile> and document it
KyleAMathews Apr 14, 2020
feddd5a
feat(recipes): Bundle react libraries into the cli (#23122)
johno Apr 15, 2020
ca5876f
Format
KyleAMathews Apr 15, 2020
4b2d5f5
Fix linting errors
KyleAMathews Apr 15, 2020
d725570
Fix more linting
KyleAMathews Apr 15, 2020
ae658e8
update snapshots
KyleAMathews Apr 15, 2020
ba56623
Squashed commit of the following:
KyleAMathews Apr 15, 2020
b52fc38
update yarn.lock
KyleAMathews Apr 15, 2020
f583af8
Merge branch 'master' into add-recipes
KyleAMathews Apr 15, 2020
b33d513
update eslint recipe
KyleAMathews Apr 15, 2020
d9eb403
fix tests
KyleAMathews Apr 15, 2020
1834ecd
Fix telemetry data
KyleAMathews Apr 15, 2020
8064fb4
chore(recipes): Move recipes code to gatsby-recipes-core (#23138)
KyleAMathews Apr 15, 2020
d7bf2b5
Add codeowners to gatsby-recipes (#23146)
johno Apr 15, 2020
ce0c719
Use dist
KyleAMathews Apr 15, 2020
348d326
chore(recipes): fix stuff (#23154)
KyleAMathews Apr 15, 2020
189abc5
fix(recipes): Update tests and fix babel config, tweak readme (#23152)
johno Apr 15, 2020
3ac2358
Merge branch 'add-recipes' of github.com:gatsbyjs/gatsby into add-rec…
KyleAMathews Apr 15, 2020
71daa66
Make the dependency type 'development' as less repetative
KyleAMathews Apr 15, 2020
3dcc4ab
update docs for release
KyleAMathews Apr 15, 2020
6a41c60
Run prettier
KyleAMathews Apr 16, 2020
64d3651
Fix lint errors
KyleAMathews Apr 16, 2020
3dd8f6c
Update
KyleAMathews Apr 16, 2020
e856272
Have gatsby depend on recipes tag
KyleAMathews Apr 16, 2020
33ee7cf
Fix site build
KyleAMathews Apr 16, 2020
c035e6c
Add note to theme-ui recipe that people need to remove any background…
KyleAMathews Apr 16, 2020
71049cd
Fix remaining package.json inconsistency
johno Apr 16, 2020
1db306b
Remove another failing giphy
KyleAMathews Apr 16, 2020
474ce42
Fix typo in package update
johno Apr 16, 2020
bc6f0e7
Fixing building .org
KyleAMathews Apr 16, 2020
f83132b
fix another
KyleAMathews Apr 16, 2020
9bbf3f4
Remove 404ed starter
KyleAMathews Apr 16, 2020
37bf95e
chore(recipes): Move recipes readme to gatsby-recipes root, add examp…
johno Apr 16, 2020
82ee210
fix(recipes): Don't write out debug log unless env var is set (#23169)
johno Apr 16, 2020
503be2c
fix(recipes): Handle errors during package installs (#23175)
johno Apr 16, 2020
b4da4dc
use what will be stable release version of gatsby-recipes to make ler…
KyleAMathews Apr 16, 2020
8194479
Add raw arguments to the IProgram type
KyleAMathews Apr 16, 2020
9724da4
fix linting error
KyleAMathews Apr 16, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,5 @@
/themes/ @gatsbyjs/themes-core
/packages/gatsby-plugin-mdx/ @gatsbyjs/themes-core
/packages/gatsby/src/bootstrap/load-themes @gatsbyjs/themes-core
/packages/gatsby-recipes/ @gatsbyjs/themes-core
/packages/gatsby/src/internal-plugins/webpack-theme-component-shadowing/ @gatsbyjs/themes-core
Original file line number Diff line number Diff line change
Expand Up @@ -102,8 +102,6 @@ When I build a Gatsby website, I like to use Netlify to handle the deployment of

Netlify has the ability to create webhooks that you can grab to say, "Hey, there's new content so you need to rebuild". I built [WP Trigger Netlify Build](https://github.com/iamtimsmith/wp-trigger-netlify-build) to make this super easy to integrate with WordPress. Simply drop in the necessary information and it will tell Netlify to rebuild when changes are made. It even shows a badge with the status of the build on the dashboard.

https://giphy.com/gifs/qyX9oq2ZmsPwk

## You have themes and plugins, now what?

Not to be too anti-climactic, but there's really not a ton more to do on the WordPress side other than create content. These plugins and theme will pretty much expose everything you need to build your Gatsby.js blog.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ In the last post, I covered setting up [WordPress for use with Gatsby](/blog/201

I have set up a WordPress site for you to use with the plugins mentioned in the last post as well as some dummy content to use. If you're curious, my favorite lorem generator is [Fillerama](http://fillerama.io/) which offers random content from Futurama, Monty Python, Star Wars, and more. This is where the content came from.

https://giphy.com/gifs/french-week-sDcfxFDozb3bO
https://giphy.com/gifs/movie-funny-HfJdu4HABDU3e

## Gatsby.js starter

Expand Down Expand Up @@ -108,7 +108,7 @@ You can see there are several dependencies installed right off the bat. I'll jus

Whew! That was a mouthful.

https://giphy.com/gifs/monty-python-and-the-holy-grail-eb3WAhXzlUAFi
https://giphy.com/gifs/movie-funny-HfJdu4HABDU3e

### Running the site

Expand Down
2 changes: 0 additions & 2 deletions docs/blog/2019-08-14-strivectin-case-study/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,6 @@ We confidently ship code to production many times per day. At the time of writin

StriVectin’s hosting costs have gone from \$2,000/month to just a few dollars per day. The servers will be decommissioned very soon.

https://giphy.com/gifs/DC4g3SGNJpC

Feature development and maintenance is much simpler. The codebase was around 20,000 files on Magento and went down to around 300.

## Final Thoughts
Expand Down
4 changes: 3 additions & 1 deletion docs/blog/2019-11-14-announcing-gatsby-cloud/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ title: "Announcing Gatsby Cloud"
date: 2019-11-14
author: "Kyle Mathews"
excerpt: "I'm excited to announce that we're launching our commercial platform, Gatsby Cloud, which will provide a growing suite of tools for web creators"
tags: ["gatsby-inc"]
tags: ["gatsby-inc", "releases", "gatsby-cloud"]
---

---

We're excited to announce the launch of [Gatsby Cloud](https://www.gatsbyjs.com/): a commercial platform of stable, trusted tools that enable web creators to build better websites.
Expand Down
9 changes: 0 additions & 9 deletions docs/starters.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4544,15 +4544,6 @@
- Based on the official Gatsby starter blog
- Uses TailwindCSS
- Uses PostCSS
- url: https://gatsby-starter-hello-world-with-header-and-footer.netlify.com/
repo: https://github.com/lgnov/gatsby-starter-hello-world-with-header-and-footer
description: Gatsby starter with a responsive barebones header and footer layout
tags:
- Styling:CSS-in-JS
features:
- Navbar and footer components with only minimal CSS that make responsiveness works
- Works in any device screen
- Easily kicking off your project with writing CSS right away
- url: https://gatsby-minimalist-starter.netlify.com/
repo: https://github.com/dylanesque/Gatsby-Minimalist-Starter
description: A minimalist, general-purpose Gatsby starter
Expand Down
13 changes: 13 additions & 0 deletions packages/gatsby-cli/src/create-cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,19 @@ function buildLocalCommands(cli, isLocalSite) {
return cmd(args)
}),
})
cli.command({
command: `recipes`,
desc: `Run a recipe`,
handler: handlerP(
getCommandHandler(`recipes`, (args, cmd) => {
cmd(args)
// Return an empty promise to prevent handlerP from exiting early.
// The recipe command shouldn't ever exit until the user directly
// kills it so this is fine.
return new Promise(resolve => {})
})
),
})
}

function isLocalGatsbySite() {
Expand Down
209 changes: 209 additions & 0 deletions packages/gatsby-recipes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
# Gatsby Recipes

Gatsby Recipes is framework for automating common Gatsby tasks. Recipes are MDX
files which, when run by our interpretor, perform common actions like installing
NPM packages, installing plugins, creating pages, etc.

It's designed to be extensible so new capabilities can be added which allow
Recipes to automate more things.

We chose MDX to allow for a literate programming style of writing recipes which
enables us to port our dozens of recipes from
https://www.gatsbyjs.org/docs/recipes/ as well as in the future, entire
tutorials.

[Read more about Recipes on the RFC](https://github.com/gatsbyjs/gatsby/pull/22610)

There's an umbrella issue for testing / using Recipes during its incubation stage.

Follow the issue for updates!

https://github.com/gatsbyjs/gatsby/issues/22991

## Recipe setup

Upgrade the global gatsby-cli package to the latest with recipes.

```shell
npm install -g gatsby-cli@latest
```

To confirm that this worked, run `gatsby --help` in your terminal. The output should show the recipes command.

### Running an example recipe

Now you can test out recipes! Start with a recipe for installing `emotion` by following these steps:

1. Create a new Hello World Gatsby site:

```shell
gatsby new try-emotion https://github.com/gatsbyjs/gatsby-starter-hello-world
```

1. Navigate into that project directory:

```shell
cd try-emotion
```

1. Now you can run the `emotion` recipe with this command:

```shell
gatsby recipes emotion
```

![Terminal showing "gatsby recipes emotion" output](https://user-images.githubusercontent.com/1424573/79452177-f3362f00-7fa4-11ea-903a-e28472bf95b6.png)

You can see a list of other recipes to run by running `gatsby recipes`

![Terminal showing recipes list](https://user-images.githubusercontent.com/1424573/79452254-14971b00-7fa5-11ea-9bdf-021c341afb10.png)

## Developing Recipes

### An example MDX recipe

Here's how you would write the `gatsby recipes emotion` recipe you just ran:

```mdx
# Setup Gatsby with Emotion

[Emotion](https://emotion.sh/) is a powerful CSS-in-JS library that supports both inline CSS styles and styled components. You can use each styling feature individually or together in the same file.

<!-- use three dashes to separate steps of the recipe -->

---

Install necessary NPM packages

<!-- refer to the API in this doc to see what APIs are available, like `NPMPackage` -->

<NPMPackage name="gatsby-plugin-emotion" />
<NPMPackage name="@emotion/core" />
<NPMPackage name="@emotion/styled" />

---

Install the Emotion plugin in gatsby-config.js

<GatsbyPlugin name="gatsby-plugin-emotion" />

---

Sweet, now it's ready to go.

Let's also write out an example page you can use to play
with Emotion.

<File
path="src/pages/emotion-example.js"
content="https://gist.githubusercontent.com/KyleAMathews/323bacd551df46e8e7b6146cbf827d0b/raw/5c60f168f30c505cff1ff2433e69dabe27ae9738/sample-emotion.js"
/>

---

Read more about Emotion on the official Emotion docs site:

https://emotion.sh/docs/introduction
```

### How to run recipes

You can run built-in recipes, ones you write locally, and ones people have posted online.

To run a local recipe, make sure to start the path to the recipe with a period like `gatsby recipes ./my-cool-recipe.mdx`

To run a remote recipe, just paste in the path to the recipe e.g. `gatsby recipes https://example.com/sweet-recipe.mdx`

### Recipe API

#### `<GatsbyPlugin>`

Installs a Gatsby Plugin in the site's `gatsby-config.js`.

Soon will support options.

```jsx
<GatsbyPlugin name="gatsby-plugin-emotion" />
```

##### props

- **name** name of the plugin

#### `<GatsbyShadowFile>`

<GatsbyShadowFile theme="gatsby-theme-blog" path="src/components/seo.js" />

##### props

- **theme** the name of the theme (or plugin) which provides the file you'd like to shadow
- **path** the path to the file within the theme. E.g. the example file above lives at `node_modules/gatsby-theme-blog/src/components/seo.js`

#### `<NPMPackage>`

`<NPMPackage name="lodash" version="latest" />`

##### props

- **name**: name of the package(s) to install. Takes a string or an array of strings.
- **version**: defaults to latest
- **dependencyType**: defaults to `production`. Other options include `development`

#### `<NPMScript>`

`<NPMScript name="test" command="jest" />`

##### props

- **name:** name of the command
- **command** the command that's run when the script is called

#### `<File>`

<File path="test.md" content="https://raw.githubusercontent.com/KyleAMathews/test-recipes/master/gatsby-recipe-jest.mdx" />

##### props

- **path** path to the file that should be created. The path is local to the root of the Node.js project (where the package.json is)
- **content** URL to the content that should be written to the path. Eventually we'll support directly putting content here after some fixees to MDX.

> Note that this content is stored in a [GitHub gist](https://gist.github.com/). When linking to a gist you'll want to click on the "Raw" button and copy the URL from that page.

## FAQ / common issues

### Q) My recipe is combining steps instead of running them seperately!

We use the `---` break syntax from Markdown to separate steps.

One quirk with it is for it to work, it must have an empty line above it.

So this will work:

```mdx
# Recipes

---

a step

<File src="something.txt" content="something" />
```

But this won't

```mdx
# Recipes

---

a step

<File src="something.txt" content="something" />
```

### Q) What kind of recipe should I write?

If you’d like to write a recipe, there are two great places to get an idea:

- Think of a task that took you more time than other tasks in the last Gatsby site you built. Is there a way to automate any part of that task?
- Look at this list of recipes in the Gatsby docs. Many of these can be partially or fully automated through creating a recipe `mdx` file. https://www.gatsbyjs.org/docs/recipes/
7 changes: 7 additions & 0 deletions packages/gatsby-recipes/babel.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// This being a babel.config.js file instead of a .babelrc file allows the
// packages in `internal-plugins` to be compiled with the rest of the source.
// Ref: https://github.com/babel/babel/pull/7358

const configPath = require(`path`).join(__dirname, `..`, `..`, `.babelrc.js`)

module.exports = require(configPath)
1 change: 1 addition & 0 deletions packages/gatsby-recipes/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// noop
Loading