Skip to content

Commit

Permalink
Expand create block options and add readme.txt template (#20694)
Browse files Browse the repository at this point in the history
* Add Author, License and Version prompt options

* Add readme.txt template

* Fix typo

* Add License URI option

* Do not filter, just assume the default value

* Update default values

* Use version option in documentation

* Update the default description field to add details on limits

* Update readme description

* Remove extra spaces

* Update packages/create-block/lib/prompts.js

* Apply suggestions from code review

Co-authored-by: Grzegorz (Greg) Ziółkowski <[email protected]>
  • Loading branch information
pereirinha and gziolo committed Mar 13, 2020
1 parent 565fce6 commit e825ed9
Show file tree
Hide file tree
Showing 5 changed files with 150 additions and 0 deletions.
29 changes: 29 additions & 0 deletions packages/create-block/lib/prompts.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,40 @@ const category = {
choices: [ 'common', 'embed', 'formatting', 'layout', 'widgets' ],
};

const author = {
type: 'input',
name: 'author',
message:
'The list of contributors containing only WordPress.org usernames (optional):',
};

const license = {
type: 'input',
name: 'license',
message: 'The plugin license (optional):',
};

const licenseURI = {
type: 'input',
name: 'licenseURI',
message: 'The plugin license URI (optional):',
};

const version = {
type: 'input',
name: 'version',
message: 'The plugin version (optional):',
};

module.exports = {
slug,
namespace,
title,
description,
dashicon,
category,
author,
license,
licenseURI,
version,
};
2 changes: 2 additions & 0 deletions packages/create-block/lib/scaffold.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ module.exports = async function(
category,
author,
license,
licenseURI,
version,
}
) {
Expand All @@ -46,6 +47,7 @@ module.exports = async function(
version,
author,
license,
licenseURI,
textdomain: namespace,
};
await Promise.all(
Expand Down
5 changes: 5 additions & 0 deletions packages/create-block/lib/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const dashicon = 'smiley';
const category = 'widgets';
const author = 'The WordPress Contributors';
const license = 'GPL-2.0-or-later';
const licenseURI = 'https://www.gnu.org/licenses/gpl-2.0.html';
const version = '0.1.0';

const templates = {
Expand All @@ -23,6 +24,7 @@ const templates = {
category,
author,
license,
licenseURI,
version,
},
outputFiles: [
Expand All @@ -31,6 +33,7 @@ const templates = {
'index.js',
'$slug.php',
'style.css',
'readme.txt',
],
},
esnext: {
Expand All @@ -44,6 +47,7 @@ const templates = {
category,
author,
license,
licenseURI,
version,
},
outputFiles: [
Expand All @@ -53,6 +57,7 @@ const templates = {
'src/index.js',
'$slug.php',
'style.css',
'readme.txt',
],
wpScriptsEnabled: true,
},
Expand Down
57 changes: 57 additions & 0 deletions packages/create-block/lib/templates/es5/readme.txt.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
=== {{title}} ===
Contributors: {{author}}
Tags: block
Requires at least: 5.3.2
Tested up to: 5.3.2
Stable tag: {{version}}
Requires PHP: 7.0.0
License: {{license}}
License URI: {{{licenseURI}}}

{{description}}

== Description ==

This is the long description. No limit, and you can use Markdown (as well as in the following sections).

For backwards compatibility, if this section is missing, the full length of the short description will be used, and
Markdown parsed.

== Installation ==

This section describes how to install the plugin and get it working.

e.g.

1. Upload the plugin files to the `/wp-content/plugins/{{slug}}` directory, or install the plugin through the WordPress plugins screen directly.
1. Activate the plugin through the 'Plugins' screen in WordPress


== Frequently Asked Questions ==

= A question that someone might have =

An answer to that question.

= What about foo bar? =

Answer to foo bar dilemma.

== Screenshots ==

1. This screen shot description corresponds to screenshot-1.(png|jpg|jpeg|gif). Note that the screenshot is taken from
the /assets directory or the directory that contains the stable readme.txt (tags or trunk). Screenshots in the /assets
directory take precedence. For example, `/assets/screenshot-1.png` would win over `/tags/4.3/screenshot-1.png`
(or jpg, jpeg, gif).
2. This is the second screen shot

== Changelog ==

= {{version}} =
* Release

== Arbitrary section ==

You may provide arbitrary sections, in the same format as the ones above. This may be of use for extremely complicated
plugins where more information needs to be conveyed that doesn't fit into the categories of "description" or
"installation." Arbitrary sections will be shown below the built-in sections outlined above.
57 changes: 57 additions & 0 deletions packages/create-block/lib/templates/esnext/readme.txt.mustache
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
=== {{title}} ===
Contributors: {{author}}
Tags: block
Requires at least: 5.3.2
Tested up to: 5.3.2
Stable tag: {{version}}
Requires PHP: 7.0.0
License: {{license}}
License URI: {{{licenseURI}}}

{{description}}

== Description ==

This is the long description. No limit, and you can use Markdown (as well as in the following sections).

For backwards compatibility, if this section is missing, the full length of the short description will be used, and
Markdown parsed.

== Installation ==

This section describes how to install the plugin and get it working.

e.g.

1. Upload the plugin files to the `/wp-content/plugins/{{slug}}` directory, or install the plugin through the WordPress plugins screen directly.
1. Activate the plugin through the 'Plugins' screen in WordPress


== Frequently Asked Questions ==

= A question that someone might have =

An answer to that question.

= What about foo bar? =

Answer to foo bar dilemma.

== Screenshots ==

1. This screen shot description corresponds to screenshot-1.(png|jpg|jpeg|gif). Note that the screenshot is taken from
the /assets directory or the directory that contains the stable readme.txt (tags or trunk). Screenshots in the /assets
directory take precedence. For example, `/assets/screenshot-1.png` would win over `/tags/4.3/screenshot-1.png`
(or jpg, jpeg, gif).
2. This is the second screen shot

== Changelog ==

= {{version}} =
* Release

== Arbitrary section ==

You may provide arbitrary sections, in the same format as the ones above. This may be of use for extremely complicated
plugins where more information needs to be conveyed that doesn't fit into the categories of "description" or
"installation." Arbitrary sections will be shown below the built-in sections outlined above.

0 comments on commit e825ed9

Please sign in to comment.