Open bobbingwide opened 4 years ago
Some additional information. Having fixed the problem, and before doing anything else I decided to try running the command interactively. The generated code had a different, unexpected value for the namespace.
C:\apache\htdocs\wordpress\wp-content\plugins>npm init @webdevstudios/block
npx: installed 85 in 11.444s
(node:15224) ExperimentalWarning: The fs.promises API is experimental
? The block slug used for identification (also the plugin and output folder name): wds-children-block
? The internal namespace for the block name (something unique for your products): wds
? The display title for your block: Children block
? The short description for your block (optional): List children of the current content as links - WDS
? The dashicon to make it easier to identify your block (optional): smiley
? The category name to help users browse and discover your block: widgets
? The name of the plugin author (optional). Multiple authors may be listed using commas: bobbingwide
? The short name of the plugin’s license (optional): GPL-2.0-or-later
? A link to the full text of the license (optional): https://www.gnu.org/licenses/gpl-2.0.html
? The current version number of the plugin: 0.1.1
Creating a new WordPress block in "wds-wds-children-block" folder.
Installing packages. It might take a couple of minutes.
Compiling block.
Done: block "Children block" bootstrapped in the "wds-wds-children-block" folder.
This is also used for the @package
The interactive logic gives you a chance to confirm your responses
Also, I was rather surprised to see that wp-scripts
will happily overwrite an existing plugin.
C:\apache\htdocs\wordpress\wp-content\plugins>npm init @webdevstudios/block
npx: installed 85 in 8.307s
(node:34840) ExperimentalWarning: The fs.promises API is experimental
? The block slug used for identification (also the plugin and output folder name): children-block
? The internal namespace for the block name (something unique for your products): wds
? The display title for your block: Children block
? The short description for your block (optional): List children of the current content as links - WDS
? The dashicon to make it easier to identify your block (optional): smiley
? The category name to help users browse and discover your block: widgets
? The name of the plugin author (optional). Multiple authors may be listed using commas: bobbingwide
? The short name of the plugin’s license (optional): GPL-2.0-or-later
? A link to the full text of the license (optional): https://www.gnu.org/licenses/gpl-2.0.html
? The current version number of the plugin: 0.1.1
Creating a new WordPress block in "wds-children-block" folder.
Installing packages. It might take a couple of minutes.
Compiling block.
Done: block "Children block" bootstrapped in the "wds-children-block" folder.
Existing contents overwritten. Good thing:
Hey @bobbingwide,
Thank you for creating this issue and for providing all the details. Greatly appreciate it! As for the first issue, the scaffolding tool is expecting the format in PascalCase. For example, instead of
npm init @webdevstudios/block wds/children-block
it should be
npm init @webdevstudios/block WDS/ChildrenBlock
Although, I don't see any problems supporting kebab-case as well.
As for the 2nd issue, thanks for catching this. I'll try to create fix as time permits.
Appreciate your time putting this issue together.
BTW: We discussed this, and other things related to scaffolding for blocks, in WP_Hooked last night.
I found the interactive method to be far more intuitive than the parameterised version.
Other requirements for the script are:
I ran
to create a new plugin for a block called children-block
The namepace that was generated in the PHP was
When I tried to activate the plugin I got the Syntax error
Workaround
change the hyphen(s) in the name space to underscore (_).