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

Remove block mu-plugin, add block.json checking workflow #23

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
29 changes: 29 additions & 0 deletions .github/workflows/block-json-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Test for block.json files.

on:
pull_request:
branches: [ trunk, develop ]

jobs:
block-file-check:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- name: Get all files
id: changed-block-json-files
uses: tj-actions/changed-files@v44

- name: Leave a comment and reject PR if block.json file is present
if: contains(steps.changed-block-json-files.outputs.all_changed_files, 'block.json')
uses: actions/github-script@v7
with:
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: '> [!CAUTION]\n> This PR includes a `block.json` file. If you are adding a new block, please ensure this goes into [the WPCOM Special Projects Monorepo](https://github.com/a8cteam51/special-projects-blocks-monorepo) instead. You will find[ full documentation on the process here](https://github.com/a8cteam51/special-projects-blocks-monorepo/wiki). Please discuss with WPComSP Engineering Leads if you believe your block should be exempt from the monorepo.'
})
core.setFailed('This PR included a block.json file and so was rejected.')
1 change: 0 additions & 1 deletion .github/workflows/fill-in-scaffold.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ jobs:
git submodule update
git mv --force README.scaffold.md README.md
git mv themes/build-processes-demo themes/${{ github.event.repository.name }}
git mv mu-plugins/build-processes-demo-blocks mu-plugins/${{ github.event.repository.name }}-blocks
git mv mu-plugins/build-processes-demo-features mu-plugins/${{ github.event.repository.name }}-features

- name: Commit the changed files.
Expand Down
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ mu-plugins/*
!mu-plugins/mu-loader.php
!mu-plugins/colophon
!mu-plugins/team51-tracking
!mu-plugins/build-processes-demo-blocks
!mu-plugins/build-processes-demo-features

themes/*
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,7 @@ FSE template parts are included in this to show desired folder structure only. Y

### Gutenberg blocks

All custom-built blocks must be placed in a mu-plugin. The demo project contains a mu-plugin called `build-processes-demo-blocks` which exemplifies building two blocks called `build-processes-demo/foobar` and `build-processes-demo/spamham`, respectively.

By separating the blocks from the theme into a mu-plugin, we can ensure that the blocks are always available on the site, even if the theme is changed (e.g., because of a future redesign or as part of the debugging process). Moreover, it forces us, as developers, to think about the blocks as a separate entity from the theme and to design the code as such thus making it easier to reuse them in other projects.

The mu-plugin must contain enough CSS for the block to be functional and not appear broken. All other styling can be held in the mu-plugin or the theme. [Seedlet is an example](https://github.com/Automattic/themes/tree/trunk/seedlet/assets/sass/blocks) of a theme providing its own styling for the blocks.
Custom blocks should now use the [WPCom Special Projects Blocks Monorepo](https://github.com/a8cteam51/special-projects-blocks-monorepo). You'll find full written documentation for how to use this system [in the Wiki of the repo](https://github.com/a8cteam51/special-projects-blocks-monorepo/wiki).

### Features plugin

Expand Down
13 changes: 0 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,22 @@
"scripts": {
"format:php": [
"@format:php:theme",
"@format:php:blocks",
"@format:php:features"
],
"format:php:theme": "phpcbf --standard=./themes/build-processes-demo/.phpcs.xml.dist --basepath=. ./themes/build-processes-demo -v",
"format:php:blocks": "phpcbf --standard=./mu-plugins/build-processes-demo-blocks/.phpcs.xml.dist --basepath=. ./mu-plugins/build-processes-demo-blocks -v",
"format:php:features": "phpcbf --standard=./mu-plugins/build-processes-demo-features/.phpcs.xml.dist --basepath=. ./mu-plugins/build-processes-demo-features -v",

"lint:php": [
"@lint:php:theme",
"@lint:php:blocks",
"@lint:php:features"
],
"lint:php:theme": "phpcs --standard=./themes/build-processes-demo/.phpcs.xml.dist --basepath=. ./themes/build-processes-demo -v",
"lint:php:blocks": "phpcs --standard=./mu-plugins/build-processes-demo-blocks/.phpcs.xml.dist --basepath=. ./mu-plugins/build-processes-demo-blocks -v",
"lint:php:features": "phpcs --standard=./mu-plugins/build-processes-demo-features/.phpcs.xml.dist --basepath=. ./mu-plugins/build-processes-demo-features -v",

"internationalize": [
"@makepot:theme",
"@updatepo:theme",

"@makepot:blocks",
"@updatepo:blocks",
"@makejson:blocks",

"@makepot:features",
"@updatepo:features"
],
Expand All @@ -79,11 +71,6 @@
"updatepo:theme": "wp i18n update-po themes/build-processes-demo/languages/build-processes-demo.pot",
"makemo:theme": "wp i18n make-mo themes/build-processes-demo/languages",

"makepot:blocks": "wp i18n make-pot mu-plugins/build-processes-demo-blocks",
"updatepo:blocks": "wp i18n update-po mu-plugins/build-processes-demo-blocks/languages/build-processes-demo-blocks.pot",
"makejson:blocks": "wp i18n make-json mu-plugins/build-processes-demo-blocks/languages --pretty-print --no-purge",
"makemo:blocks": "wp i18n make-mo mu-plugins/build-processes-demo-blocks/languages",

"makepot:features": "wp i18n make-pot mu-plugins/build-processes-demo-features",
"updatepo:features": "wp i18n update-po mu-plugins/build-processes-demo-features/languages/build-processes-demo-features.pot",
"makemo:features": "wp i18n make-mo mu-plugins/build-processes-demo-features/languages",
Expand Down
28 changes: 0 additions & 28 deletions mu-plugins/build-processes-demo-blocks/.phpcs.xml.dist

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions mu-plugins/build-processes-demo-blocks/build/foobar/block.json

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

18 changes: 0 additions & 18 deletions mu-plugins/build-processes-demo-blocks/build/spamham/block.json

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

1 change: 0 additions & 1 deletion mu-plugins/build-processes-demo-blocks/includes/index.php

This file was deleted.

41 changes: 0 additions & 41 deletions mu-plugins/build-processes-demo-blocks/includes/plugin-setup.php

This file was deleted.

1 change: 0 additions & 1 deletion mu-plugins/build-processes-demo-blocks/index.php

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading