Skip to content

Commit

Permalink
Scaffolding: Add new keywordssection, and placeholder screenshot. (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Clorith authored Jun 13, 2023
1 parent f1595ed commit f53cdc5
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 6 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Options:
--title <value> display title for the block
--short-description <value> short description for the block
--category <name> category name for the block
--keywords <value> keywords of the blocks use, and relationships, for example `T2`
-h, --help output usage information
```

Expand Down
3 changes: 3 additions & 0 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ program
// The name "description" is used internally so it couldn't be used.
.option( '--short-description <value>', 'short description for the block' )
.option( '--category <name>', 'category name for the block' )
.option( '--keywords <value>', 'keywords of the blocks use, and relationships, for example `T2`' )
.action(
async (
slug,
Expand All @@ -50,6 +51,7 @@ program
namespace,
shortDescription: description,
title,
keywords
}
) => {
try {
Expand All @@ -61,6 +63,7 @@ program
description,
namespace,
title,
keywords,
},
( value ) => value !== undefined
);
Expand Down
12 changes: 11 additions & 1 deletion lib/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,21 @@ const title = {
const description = {
type: 'input',
name: 'description',
message: 'The short description for your block (optional):',
message: 'The short description for your block:',
filter( input ) {
return input && upperFirst( input );
},
};

const keywords = {
type: 'input',
name: 'keywords',
message: 'Keywords of the blocks use, and relationships, for example `T2` (optional):',
filter( input ) {
return input;
},
};

const category = {
type: 'list',
name: 'category',
Expand All @@ -69,4 +78,5 @@ module.exports = {
title,
description,
category,
keywords,
};
5 changes: 3 additions & 2 deletions lib/scaffold.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const { code, info, success } = require( './log' );

module.exports = async (
blockTemplate,
{ namespace, slug, title, description, category }
{ namespace, slug, title, description, category, keywords }
) => {
slug = slug.toLowerCase();
namespace = namespace.toLowerCase();
Expand All @@ -31,6 +31,7 @@ module.exports = async (
title,
description,
category,
keywords,
textdomain: namespace,
phpnamespace: capitalize( snakeCase( namespace ) ),
phpnamespaceslug: capitalize( snakeCase( slug ) ),
Expand Down Expand Up @@ -65,7 +66,7 @@ module.exports = async (
);
info( '' );

info( 'Remember to install the new plugin with composer. Run:' );
info( 'Remember to add a screenshot, and install the new plugin with composer. Run:' );
code( ` composer require ${ namespace }/block-${ slug }:~1.0.0` );
info( 'To get started' );

Expand Down
4 changes: 3 additions & 1 deletion lib/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const predefinedBlockTemplates = {
namespace: 'project-name',
title: 'Block Name',
description: 'Example block description.',
keywords: 'T2',
},
templatesPath: join( __dirname, 'templates', 'plain' ),
},
Expand All @@ -28,13 +29,14 @@ const predefinedBlockTemplates = {
namespace: 'project-name',
title: 'Block Name',
description: 'Example block description.',
keywords: 'T2',
},
templatesPath: join( __dirname, 'templates', 'innerblocks' ),
},
};

const getOutputTemplates = async ( outputTemplatesPath ) => {
const outputTemplatesFiles = await glob( '**/*.mustache', {
const outputTemplatesFiles = await glob( [ '**/*.mustache', '**/screenshot.png' ], {
cwd: outputTemplatesPath,
dot: true,
} );
Expand Down
3 changes: 2 additions & 1 deletion lib/templates/innerblocks/composer.json.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"description": "{{description}}",
"type": "wordpress-plugin",
"license": "GPL-3.0-or-later",
"version": "1.0.0"
"version": "1.0.0",
"keywords": "{{keywords}}"
}
Binary file added lib/templates/innerblocks/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion lib/templates/plain/composer.json.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"description": "{{description}}",
"type": "wordpress-plugin",
"license": "GPL-3.0-or-later",
"version": "1.0.0"
"version": "1.0.0",
"keywords": "{{keywords}}"
}
Binary file added lib/templates/plain/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit f53cdc5

Please sign in to comment.