Skip to content

Commit f2bd740

Browse files
authored
chore: Switch tutorial to use wp-env and Docker (#2221)
* Switch tutorial to use wp-env and Docker Replaces wp-now and blueprint setup with @wordpress/env and Docker for local WordPress development in the Faust.js tutorial. Updates documentation, environment example, and removes faust-tutorial-blueprint.json in favor of .wp-env.json. Changes all references and ports from 8881 to 8888 for consistency. * npx degit wpengine/faustjs/examples/next/tutorial#issue-2211 faust-tutorial * remove accidental directory * Delete tutorial-wp-env-migration.md
1 parent a3bcf2e commit f2bd740

File tree

6 files changed

+1607
-36
lines changed

6 files changed

+1607
-36
lines changed

docs/tutorial/learn-faust/index.md

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,9 @@ In order to complete this tutorial, you should:
1919
- Be familiar with [cloning a repository from GitHub](https://docs.github.com/en/repositories/creating-and-managing-repositories/cloning-a-repository)
2020
- Be comfortable running commands on the [command line](https://en.wikipedia.org/wiki/Command-line_interface)
2121
- Have [Node.js and NPM](https://nodejs.org/) installed on your computer
22+
- Have [Docker Desktop](https://www.docker.com/products/docker-desktop) installed and running on your computer
2223

23-
You should also not have any other projects running on port `3000` or `8881`, since the links in this tutorial point to pages on those ports.
24+
You should also not have any other projects running on port `3000` or `8888`, since the links in this tutorial point to pages on those ports.
2425

2526
## Set up
2627

@@ -39,12 +40,16 @@ npx degit wpengine/faustjs/examples/next/tutorial faust-tutorial
3940
Initial set up steps:
4041

4142
- `cd` into the `/faust-tutorial` project folder.
42-
- Run `npm run wp-dev`. This command uses the [`wp-now`](https://www.npmjs.com/package/@wp-now/wp-now) NPM package and the included [`faust-tutorial-blueprint.json`](https://github.com/wpengine/faustjs/blob/canary/examples/next/tutorial/faust-tutorial-blueprint.json) blueprint file to set up a local WordPress environment.
43-
- When asked if it's okay to install the `@wp-now/wp-now` package, answer `y` to confirm.
43+
- Run `npm install` to install dependencies, including the [`@wordpress/env`](https://developer.wordpress.org/block-editor/getting-started/devenv/get-started-with-wp-env/) package.
44+
- Run `npm run wp-dev` to start the local WordPress environment using wp-env. This will use Docker to create a WordPress instance with the required plugins.
4445

4546
After a moment, you should have a WordPress site up-and-running.
4647

47-
By navigating to http://localhost:8881/wp-admin/plugins.php, You can see that the required [FaustWP](https://wordpress.org/plugins/faustwp/) and [WPGraphQL](https://wordpress.org/plugins/wp-graphql/) plugins have already been installed for you.
48+
By navigating to http://localhost:8888/wp-admin, you can access the WordPress admin. The default credentials are:
49+
- Username: `admin`
50+
- Password: `password`
51+
52+
You can see that the required [FaustWP](https://wordpress.org/plugins/faustwp/) and [WPGraphQL](https://wordpress.org/plugins/wp-graphql/) plugins have already been installed for you by checking http://localhost:8888/wp-admin/plugins.php.
4853

4954
Next, we'll just configure a few last things in WordPress.
5055

@@ -70,7 +75,7 @@ Follow these steps to set up your Faust.js frontend:
7075

7176
```env title=".env.local"
7277
# Your WordPress site URL
73-
NEXT_PUBLIC_WORDPRESS_URL=http://localhost:8881
78+
NEXT_PUBLIC_WORDPRESS_URL=http://localhost:8888
7479
7580
# Plugin secret found in WordPress Settings->Faust
7681
FAUST_SECRET_KEY=ABC123
@@ -166,7 +171,7 @@ export default templates;
166171
167172
This tells Faust to use the `PageTemplate` component as the template to render pages that match `page`, according to the template hierarchy.
168173
169-
Save your changes and visit [http://localhost:3000/sample-page/](http://localhost:3000/sample-page/) in a browser. You should be able to see the title and content for the [Sample Page page in WordPress](http://localhost:8881/wp-admin/post.php?post=2&action=edit).
174+
Save your changes and visit [http://localhost:3000/sample-page/](http://localhost:3000/sample-page/) in a browser. You should be able to see the title and content for the [Sample Page page in WordPress](http://localhost:8888/wp-admin/post.php?post=2&action=edit).
170175
171176
Now that you understand how to leverage the template hierarchy, you can follow this pattern to add additional page templates:
172177
@@ -381,7 +386,7 @@ You should now be able to visit http://localhost:3000/blog/hello-world/ and see
381386

382387
Inspect the blog post content in the browser dev tools and notice that each block is being rendered and that only the paragraph blocks are wrapped in a `div` with a class name of `paragraph-block-wrapper`. Currently, we're not leveraging the `paragraph-block-wrapper` class in any way, but you can see the potential here. By being able to query for and render blocks individually, you have the ability to wrap specific blocks in arbitrary markup, override specific blocks with custom implementations, and more.
383388
384-
Now [edit the Hello World! blog post](http://localhost:8881/wp-admin/post.php?post=1&action=edit). Make several changes to it in terms of font size, padding, margin, a border, an HTML anchor, and additional CSS classes, then save your changes.
389+
Now [edit the Hello World! blog post](http://localhost:8888/wp-admin/post.php?post=1&action=edit). Make several changes to it in terms of font size, padding, margin, a border, an HTML anchor, and additional CSS classes, then save your changes.
385390
386391
Reload the http://localhost:3000/blog/hello-world/ page in your frontend app and see that all the changes you applied are now being reflected. Inspect the paragraph block in DevTools to see markup similar to the example below. You can see that Faust has taken care of rendering the paragraph tag to include these attributes, and even loaded the CSS required to apply the correct styles.
387392
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Your WordPress site URL
2-
NEXT_PUBLIC_WORDPRESS_URL=http://localhost:8881
2+
NEXT_PUBLIC_WORDPRESS_URL=http://localhost:8888
33

44
# Plugin secret found in WordPress Settings->Faust
55
FAUST_SECRET_KEY=
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"plugins": [
3+
"https://downloads.wordpress.org/plugin/wp-graphql.latest-stable.zip",
4+
"https://downloads.wordpress.org/plugin/faustwp.latest-stable.zip"
5+
],
6+
"port": 8888,
7+
"config": {
8+
"WP_DEBUG": true,
9+
"WP_DEBUG_LOG": true,
10+
"WP_DEBUG_DISPLAY": false
11+
}
12+
}

examples/next/tutorial/faust-tutorial-blueprint.json

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)