-
Notifications
You must be signed in to change notification settings - Fork 136
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
Add faust blockset
command
#1585
Merged
Merged
Changes from 107 commits
Commits
Show all changes
108 commits
Select commit
Hold shift + click to select a range
464b4c3
Add new block-support example project
josephfusco 1be9609
Auto analyze new project
josephfusco 377942f
Update dependencies
josephfusco dfea166
Remove hardcoded theme.json
josephfusco d1e2db5
Ignore globalStylesheet.css
josephfusco e7c9075
Reduce example to just block things
josephfusco 929f37a
Add newline to EOF
josephfusco 1bc1645
Reduce example
josephfusco b8627b6
Merge branch 'canary' into nojira-block-support-example
josephfusco 29d10da
Update lockfile after merge
josephfusco 4257d0e
Constrain layout using existing core class
josephfusco da3c5bf
Not being used
josephfusco b9a235c
Irrelevant comment
josephfusco 34334ba
Merge branch 'canary' into nojira-block-support-example
josephfusco 5f4c85a
Merge branch 'canary' into nojira-block-support-example
josephfusco fed767d
Scaffold out new plugin files
josephfusco e1dcc3a
Add new dependencies
josephfusco 85b5b6e
Add blockset command
josephfusco cef820f
Add new command to block support example
josephfusco 574078d
Register new REST endpoint to handle unzipping blocks
josephfusco 92e62a9
Fix example project deps
josephfusco a9da48f
Fix namespace issue
josephfusco b9ba524
Refactor into testable functions
josephfusco 6cb61e1
Mock custom block
josephfusco d00d39c
Ignore .faust
josephfusco 1389e03
Fix namespacing issues in WP plugin
josephfusco 9f8e189
Clean up comments
josephfusco df858e7
Improve readability
josephfusco c29d432
Add deps
josephfusco b1b1d3b
Add second block example to test blockset
josephfusco 419bb8b
Export functions for tests
josephfusco 762b762
Remove unused jest-dom in CLI package
josephfusco 037a7c1
Remove unused package
josephfusco 0e426cf
Add new utility function
josephfusco bbe7e55
Ignore for tests
josephfusco 1e3745e
Refactor blockset command
josephfusco 98bc082
New line at EOF
josephfusco 88ccd17
Linting fixes
josephfusco 2259219
Return true upon success
josephfusco 80fead9
Use available logging methods
josephfusco b7383ad
Remove code already in handle_uploaded_blockset & setup translations
josephfusco b12f11f
Add missing dep
josephfusco 87e6268
Linting fixes
josephfusco c88b4cb
Linting fixes
josephfusco 7d8db16
Merge branch 'canary' into nojira-block-support-example
josephfusco c9dd1f8
Resolve merge conflicts
josephfusco d668c1c
Merge branch 'nojira-block-support-example' into nojira-add-blockset-…
josephfusco 4a71216
Feat: Add compileBlocks step.
theodesp 808d2a4
Automatically load custom blocks from uploads
josephfusco 6a8657d
Fix enqueues from the uploads directory
josephfusco 958ad70
Fix linting issues
josephfusco 6150bb3
Feat: Check if project uses yarn when compiling blocks
theodesp 086a656
Use enqueue_block_editor_assets to avoid unnecessary runs
josephfusco c4aa34d
Remove explicit registration using args
josephfusco e111cb2
Add required titles
josephfusco c3c6425
Correct the asset src for the blocks in uploads
josephfusco 904b760
Merge branch 'nojira-add-blockset-command' of github.com:wpengine/fau…
josephfusco 41f0199
Linting fixes
josephfusco 92dd89c
Remove unused functions
josephfusco bbcf423
Deps: Add wp-scripts in peer deps.
theodesp e8d42a2
Chore: Add changeset.
theodesp 02a0039
Deps: Update rimraf
theodesp ccf5928
Chore: Update deps.
theodesp c8737e9
Merge branch 'canary' into nojira-add-blockset-command
josephfusco 7297578
Refactor: Update hasYarn
theodesp ac7bc05
Merge branch 'nojira-add-blockset-command' of github.com:wpengine/fau…
theodesp 65ee414
Merge remote-tracking branch 'origin' into nojira-add-blockset-command
theodesp 056f545
Chore: Update package-lock
theodesp 5b0c8fc
Chore: update package-lock again
theodesp 037d5ac
Chore: add missing export.
theodesp 9a4a812
Chore: remove faust blockset from predev,prebuild
theodesp b03e8ec
Fix blocks missing from WPGraphQL & prevent unnecessary block registr…
josephfusco 129e246
Fix linting issues
josephfusco f3a67b0
Example: Add block using `registerFaustBlock` helper
theodesp 903eaee
Refactor: Update block comments
theodesp 51533eb
Add plugin tests
josephfusco 26e72cb
Merge branch 'nojira-add-blockset-command' of github.com:wpengine/fau…
josephfusco 974984e
Add Plugin Tests (#1601)
josephfusco 33b477d
Merge branch 'nojira-add-blockset-command' of github.com:wpengine/fau…
josephfusco 32a265f
Merge remote-tracking branch 'origin' into nojira-add-blockset-command
theodesp ff4c1be
Merge branch 'nojira-add-blockset-command' of github.com:wpengine/fau…
josephfusco 4e9a51f
Remove orphaned test
josephfusco e3c60e1
Track possibleTypes & globalStylesheet generated files
josephfusco 77fb05f
Build possibleTypes
josephfusco 84e45c5
Add @wordpress/scripts to block-support-example
josephfusco 8156972
Auto run blockset in block example
josephfusco e010712
Ignore Faust generated files
josephfusco b3105be
Remove previously tracked file
josephfusco 5007a2f
Fix version regression from merge conflict
josephfusco 81466fd
Refactor: Change block-C as block-B
theodesp ecf032c
Fix: Remove @ts-ignore comment.
theodesp 6b0a23e
Merge remote-tracking branch 'origin' into nojira-add-blockset-command
theodesp 4333e77
CI/CD fix tests with faustwp-cli
theodesp 4b3df8f
Example block support: Remove blockset.
theodesp 7152ae2
Chore: Code review fixes.
theodesp 666d9bf
Merge remote-tracking branch 'origin' into nojira-add-blockset-command
theodesp d5367c0
Chore: add Component.fragments
theodesp c79ff97
Merge remote-tracking branch 'origin' into nojira-add-blockset-command
theodesp a7f9c8e
Chore: Update package-lock.json
theodesp 1125b6e
Chore: Add gql missing import.
theodesp 7db0b8d
Tests: Update fromThemeJson.test snapshot.
theodesp 7913f9b
Style: Add block styles in front-end
theodesp 0f86e06
Styles: Consistent styles fixed.
theodesp a3c0ffc
CI/CD: Fix test cases.
theodesp b214c75
Test: Update CoreCode test snapshot.
theodesp 1fd4356
CI/CD: Update types in Toolbar.test.tsx
theodesp 3db3d41
CI/CD: Remove examples/next/block-support from bundle analysis.
theodesp b641ca8
Merge remote-tracking branch 'origin' into nojira-add-blockset-command
theodesp File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
--- | ||
'@faustwp/cli': minor | ||
'@faustwp/wordpress-plugin': minor | ||
--- | ||
|
||
Add blockset command in @faust/cli and faustwp plugin. | ||
|
||
Add your blocks inside `wp-blocks` folder. Then run `faust blockset` to compile and upload the blocks into WordPress. Blocks will be available in the editor. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
possibleTypes.json | ||
.faust | ||
globalStylesheet.css | ||
possibleTypes.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,3 +11,5 @@ | |
@import '@wordpress/base-styles/breakpoints'; | ||
@import '@wordpress/block-library/src/style'; | ||
@import '@wordpress/block-library/src/theme'; | ||
|
||
@import '../wp-blocks/block-b/style.scss' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. include block style here is next.js hates importing global styles within the components. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"$schema": "https://schemas.wp.org/trunk/block.json", | ||
"apiVersion": 2, | ||
"name": "create-block/block-a", | ||
"version": "0.1.0", | ||
"title": "Block A", | ||
"category": "widgets", | ||
"icon": "smiley", | ||
"description": "Example static block scaffolded with Create Block tool.", | ||
"supports": { | ||
"html": false | ||
}, | ||
"textdomain": "block-a", | ||
"editorScript": "file:./index.js", | ||
"editorStyle": "file:./index.css", | ||
"style": "file:./style-index.css" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Retrieves the translation of text. | ||
* | ||
* @see https://developer.wordpress.org/block-editor/packages/packages-i18n/ | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* React hook that is used to mark the block wrapper element. | ||
* It provides all the necessary props like the class name. | ||
* | ||
* @see https://developer.wordpress.org/block-editor/packages/packages-block-editor/#useBlockProps | ||
*/ | ||
import { useBlockProps } from '@wordpress/block-editor'; | ||
|
||
/** | ||
* Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files. | ||
* Those files can contain any CSS code that gets applied to the editor. | ||
* | ||
* @see https://www.npmjs.com/package/@wordpress/scripts#using-css | ||
*/ | ||
import './editor.scss'; | ||
|
||
/** | ||
* The edit function describes the structure of your block in the context of the | ||
* editor. This represents what the editor will render when the block is used. | ||
* | ||
* @see https://developer.wordpress.org/block-editor/developers/block-api/block-edit-save/#edit | ||
* | ||
* @return {WPElement} Element to render. | ||
*/ | ||
export default function Edit() { | ||
return ( | ||
<p {...useBlockProps()}> | ||
{__('Block A – hello from the editor!', 'block-a')} | ||
</p> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/** | ||
* The following styles get applied inside the editor only. | ||
* | ||
* Replace them with your own styles or remove the file completely. | ||
*/ | ||
|
||
.wp-block-create-block-block-a { | ||
border: 1px dotted #f00; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/** | ||
* Registers a new block provided a unique name and an object defining its behavior. | ||
* | ||
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/ | ||
*/ | ||
import { registerBlockType } from '@wordpress/blocks'; | ||
|
||
/** | ||
* Lets webpack process CSS, SASS or SCSS files referenced in JavaScript files. | ||
* All files containing `style` keyword are bundled together. The code used | ||
* gets applied both to the front of your site and to the editor. | ||
* | ||
* @see https://www.npmjs.com/package/@wordpress/scripts#using-css | ||
*/ | ||
import './style.scss'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import Edit from './edit'; | ||
import save from './save'; | ||
import metadata from './block.json'; | ||
|
||
/** | ||
* Every block starts by registering a new block type definition. | ||
* | ||
* @see https://developer.wordpress.org/block-editor/reference-guides/block-api/block-registration/ | ||
*/ | ||
registerBlockType(metadata.name, { | ||
title: 'Block A', | ||
josephfusco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
/** | ||
* @see ./edit.js | ||
*/ | ||
edit: Edit, | ||
/** | ||
* @see ./save.js | ||
*/ | ||
save, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* Retrieves the translation of text. | ||
* | ||
* @see https://developer.wordpress.org/block-editor/packages/packages-i18n/ | ||
*/ | ||
import { __ } from '@wordpress/i18n'; | ||
|
||
/** | ||
* React hook that is used to mark the block wrapper element. | ||
* It provides all the necessary props like the class name. | ||
* | ||
* @see https://developer.wordpress.org/block-editor/packages/packages-block-editor/#useBlockProps | ||
*/ | ||
import { useBlockProps } from '@wordpress/block-editor'; | ||
|
||
/** | ||
* The save function defines the way in which the different attributes should | ||
* be combined into the final markup, which is then serialized by the block | ||
* editor into `post_content`. | ||
* | ||
* @see https://developer.wordpress.org/block-editor/developers/block-api/block-edit-save/#save | ||
* | ||
* @return {WPElement} Element to render. | ||
*/ | ||
export default function save() { | ||
return ( | ||
<p {...useBlockProps.save()}> | ||
{__('Block A – hello from the saved content!', 'block-a')} | ||
</p> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
/** | ||
* The following styles get applied both on the front of your site | ||
* and in the editor. | ||
* | ||
* Replace them with your own styles or remove the file completely. | ||
*/ | ||
|
||
.wp-block-create-block-block-a { | ||
background-color: #21759b; | ||
color: #fff; | ||
padding: 2px; | ||
} |
38 changes: 38 additions & 0 deletions
38
examples/next/block-support/wp-blocks/block-b/Component.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { gql } from '@apollo/client'; | ||
|
||
function Component({ style, attributes, children, ...props }) { | ||
const styles = { | ||
...style, | ||
}; | ||
const cssClassName = 'create-block-block-b-message'; | ||
return ( | ||
<div | ||
style={styles} | ||
className={cssClassName} | ||
dangerouslySetInnerHTML={{ __html: attributes.message }} | ||
/> | ||
); | ||
} | ||
|
||
Component.fragments = { | ||
key: `CreateBlockBlockBFragment`, | ||
entry: gql` | ||
fragment CreateBlockBlockBFragment on CreateBlockBlockB { | ||
attributes { | ||
message | ||
} | ||
} | ||
`, | ||
}; | ||
|
||
Component.config = { | ||
name: 'CreateBlockBlockB', | ||
editorFields: { | ||
message: { | ||
type: 'string', | ||
label: 'My Message', | ||
location: 'editor', | ||
}, | ||
}, | ||
}; | ||
export default Component; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"$schema": "https://schemas.wp.org/trunk/block.json", | ||
"apiVersion": 2, | ||
"name": "create-block/block-b", | ||
"version": "0.1.0", | ||
"title": "Block B", | ||
"category": "widgets", | ||
"icon": "smiley", | ||
"description": "Example static block scaffolded with Create Block tool.", | ||
"supports": { | ||
"html": false | ||
}, | ||
"attributes": { | ||
"message": { | ||
"type": "string", | ||
"default": "Hello World" | ||
} | ||
}, | ||
"textdomain": "block-b", | ||
"editorScript": "file:./index.js", | ||
"editorStyle": "file:./index.css", | ||
"style": "file:./style-index.css" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { registerFaustBlock } from '@faustwp/block-editor-utils'; | ||
import './style.scss'; | ||
import BlockB from './Component.js' | ||
/** | ||
* Block.json metadata | ||
*/ | ||
import metadata from './block.json'; | ||
/** | ||
* Register React block on the Block Editor | ||
*/ | ||
registerFaustBlock(BlockB, { | ||
blockJson: metadata | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
/** | ||
* The following styles get applied both on the front of your site | ||
* and in the editor. | ||
* | ||
* Replace them with your own styles or remove the file completely. | ||
*/ | ||
|
||
.wp-block-create-block-block-b { | ||
color: #333; | ||
padding: 2px; | ||
} | ||
|
||
.create-block-block-b-message { | ||
border: 1px solid pink; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this one is problematic.