@wordpress/create-block 2.9.1-next.f435e9e01b.0 → 3.1.0-next.e230fbab09.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,12 +2,32 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- ## 2.9.0-next.0 (2022-02-23)
5
+ ## 3.0.0 (2022-03-03)
6
+
7
+ ### Breaking Changes
8
+
9
+ - It is no longer mandatory to provide the deprecated `templatesPath` option when configuring the custom project template ([#39049](https://github.com/WordPress/gutenberg/pull/39049)).
10
+ - Custom project templates will use default template files during scaffolding for the WordPress plugin shell and/or individual blocks. It is possible to replace them with a custom set of template files by using the `pluginTemplatesPath` and/or `blockTemplatesPath` options ([#39049](https://github.com/WordPress/gutenberg/pull/39049)).
11
+ - The default `esnext` project template got renamed to `static` ([#39049](https://github.com/WordPress/gutenberg/pull/39049)).
12
+
13
+ ### New Features
14
+
15
+ - Added CLI prompts for three additional plugin header fields: `Plugin URI`, `Domain Path`, and `Update URI` ([#39096](https://github.com/WordPress/gutenberg/pull/39096)).
16
+
17
+ ### Deprecations
18
+
19
+ - To remove confusion when configuring custom project templates, the `templatesPath` option got renamed to `pluginTemplatesPath`. The old name still works but is considered deprecated, and it might get removed in the future ([#39049](https://github.com/WordPress/gutenberg/pull/39049)).
20
+
21
+ ### Documentation
22
+
23
+ - Include a missing note on how to create a zip file for a WordPress plugin ([#39049](https://github.com/WordPress/gutenberg/pull/39049))
24
+
25
+ ## 2.9.0 (2022-02-10)
6
26
 
7
27
  ### New Features
8
28
 
9
- - Automatically add a `"env": "wp-env"` entry to scripts when the `--wp-env` is passed or when a template sets `wpEnv` to `true` ([#38530](https://github.com/WordPress/gutenberg/pull/38530)).
10
- - Introduce the `customScripts` property to allow templates to define additional scripts ([#38535](https://github.com/WordPress/gutenberg/pull/38535)).
29
+ - Automatically add a `"env": "wp-env"` entry to scripts when the `--wp-env` is passed or when a template sets `wpEnv` to `true` ([#38530](https://github.com/WordPress/gutenberg/pull/38530)).
30
+ - Introduce the `customScripts` property to allow templates to define additional scripts ([#38535](https://github.com/WordPress/gutenberg/pull/38535)).
11
31
 
12
32
  ## 2.8.0 (2022-01-27)
13
33
 
package/README.md CHANGED
@@ -1,18 +1,18 @@
1
1
  # Create Block
2
2
 
3
- Create Block is an officially supported way to create blocks for registering a block for a WordPress plugin. It offers a modern build setup with no configuration. It generates PHP, JS, CSS code, and everything else you need to start the project.
3
+ Create Block is an officially supported tool for scaffolding WordPress plugins with blocks. It generates PHP, JS, CSS code, and everything you need to start the project. It integrates a modern build setup with no configuration.
4
4
 
5
5
  It is largely inspired by [create-react-app](https://create-react-app.dev/docs/getting-started). Major kudos to [@gaearon](https://github.com/gaearon), the whole Facebook team, and the React community.
6
6
 
7
7
  ## Description
8
8
 
9
- Blocks are the fundamental element of the WordPress block editor. They are the primary way in which plugins and themes can register their own functionality and extend the capabilities of the editor.
9
+ Blocks are the fundamental element of the WordPress block editor. They are the primary way in which plugins can register their functionality and extend the editor's capabilities.
10
10
 
11
11
  Visit the [Gutenberg handbook](https://developer.wordpress.org/block-editor/developers/block-api/block-registration/) to learn more about Block API.
12
12
 
13
13
  ## Quick start
14
14
 
15
- You just need to provide the `slug` which is the target location for scaffolded plugin files and the internal block name.
15
+ You only need to provide the `slug` the target location for scaffolded plugin files and the internal block name.
16
16
 
17
17
  ```bash
18
18
  $ npx @wordpress/create-block todo-list
@@ -26,7 +26,7 @@ It creates a WordPress plugin that you need to [install manually](https://wordpr
26
26
 
27
27
  ## Usage
28
28
 
29
- The following command generates PHP, JS and CSS code for registering a block.
29
+ The following command generates a project with PHP, JS, and CSS code for registering a block with a WordPress plugin.
30
30
 
31
31
  ```bash
32
32
  $ npx @wordpress/create-block [options] [slug]
@@ -34,16 +34,16 @@ $ npx @wordpress/create-block [options] [slug]
34
34
 
35
35
  ![Demo](https://user-images.githubusercontent.com/699132/103872910-4de15f00-50cf-11eb-8c74-67ca91a8c1a4.gif)
36
36
 
37
- `[slug]` is optional. When provided it triggers the quick mode where it is used as the block slug used for its identification, the output location for scaffolded files, and the name of the WordPress plugin. The rest of the configuration is set to all default values unless overridden with some of the options listed below.
37
+ `[slug]` is optional. When provided, it triggers the quick mode where it is used as the block slug used for its identification, the output location for scaffolded files, and the name of the WordPress plugin. The rest of the configuration is set to all default values unless overridden with some options listed below.
38
38
 
39
39
  Options:
40
40
 
41
41
  ```bash
42
42
  -V, --version output the version number
43
- -t, --template <name> plugin template type name, allowed values: "es5", "esnext", the name of an external npm package (default: "esnext"), or the path to a local directory.
43
+ -t, --template <name> project template type name; allowed values: "static" (default), "es5", the name of an external npm package, or the path to a local directory
44
44
  --namespace <value> internal namespace for the block name
45
- --title <value> display title for the plugin/block
46
- --short-description <value> short description for the plugin/block
45
+ --title <value> display title for the block and the WordPress plugin
46
+ --short-description <value> short description for the block and the WordPress plugin
47
47
  --category <name> category name for the block
48
48
  --wp-scripts enable integration with `@wordpress/scripts` package
49
49
  --no-wp-scripts disable integration with `@wordpress/scripts` package
@@ -59,16 +59,16 @@ More examples:
59
59
  $ npx @wordpress/create-block
60
60
  ```
61
61
 
62
- 2. ES5 template – it is also possible to pick ES5 template when you don't want to deal with a build step (`npm start`) which enables ESNext and JSX support.
62
+ 2. External npm package – it is also possible to select an external npm package as a template.
63
63
 
64
64
  ```bash
65
- $ npx @wordpress/create-block --template es5
65
+ $ npx @wordpress/create-block --template my-template-package
66
66
  ```
67
67
 
68
68
  3. Local template directory – it is also possible to pick a local directory as a template.
69
69
 
70
70
  ```bash
71
- $ npx @wordpress/create-block --template ./path/to/template
71
+ $ npx @wordpress/create-block --template ./path/to/template-directory
72
72
  ```
73
73
 
74
74
  4. Help – you need to use `npx` to output usage information.
@@ -77,11 +77,11 @@ $ npx @wordpress/create-block --template ./path/to/template
77
77
  $ npx @wordpress/create-block --help
78
78
  ```
79
79
 
80
- When you scaffold a block, you must provide at least a `slug` name, the `namespace` which usually corresponds to either the `theme` or `plugin` name, and the `category`. In most cases, we recommended pairing blocks with plugins rather than themes, because only using plugin ensures that all blocks still work when your theme changes.
80
+ When you scaffold a block, you must provide at least a `slug` name, the `namespace` which usually corresponds to either the `theme` or `plugin` name. In most cases, we recommended pairing blocks with WordPress plugins rather than themes, because only using plugin ensures that all blocks still work when your theme changes.
81
81
 
82
82
  ## Available Commands
83
83
 
84
- When bootstrapped with the `esnext` template (or any external template with `wpScripts` flag enabled), you can run several commands inside the directory:
84
+ When bootstrapped with the `static` template (or any other project template with `wpScripts` flag enabled), you can run several commands inside the directory:
85
85
 
86
86
  ```bash
87
87
  $ npm start
@@ -113,6 +113,12 @@ $ npm run lint:js
113
113
 
114
114
  Lints JavaScript files. [Learn more](https://github.com/WordPress/gutenberg/tree/HEAD/packages/scripts#lint-js).
115
115
 
116
+ ```bash
117
+ $ npm run plugin-zip
118
+ ```
119
+
120
+ Creates a zip file for a WordPress plugin. [Learn more](https://github.com/WordPress/gutenberg/tree/HEAD/packages/scripts#plugin-zip).
121
+
116
122
  ```bash
117
123
  $ npm run packages-update
118
124
  ```
@@ -121,17 +127,17 @@ Updates WordPress packages to the latest version. [Learn more](https://github.co
121
127
 
122
128
  _Note: You don’t need to install or configure tools like [webpack](https://webpack.js.org), [Babel](https://babeljs.io) or [ESLint](https://eslint.org) yourself. They are preconfigured and hidden so that you can focus on coding._
123
129
 
124
- ## External Templates
130
+ ## External Project Templates
125
131
 
126
- Since version `0.19.0` it is possible to use external templates hosted on npm. These packages need to contain `.mustache` files that will be used during the block scaffolding process.
132
+ Are you looking for a way to share your project configuration? Creating an external project template hosted on npm or located in a local directory is possible. These npm packages can provide custom `.mustache` files that replace default files included in the tool for the WordPress plugin or/and the block. It's also possible to override default configuration values used during the scaffolding process.
127
133
 
128
- ### Template Configuration
134
+ ### Project Template Configuration
129
135
 
130
- It is mandatory to provide the main file (`index.js` by default) for the package that returns a configuration object. It must contain at least the `templatesPath` field.
136
+ Providing the main file (`index.js` by default) for the package that returns a configuration object is mandatory. Several options allow customizing the scaffolding process.
131
137
 
132
- #### `templatesPath`
138
+ #### `pluginTemplatesPath`
133
139
 
134
- A mandatory field with the path pointing to the location where plugin template files live (nested folders are also supported). All files without the `.mustache` extension will be ignored.
140
+ This optional field allows overriding file templates related to **the WordPress plugin shell**. The path points to a location with template files ending with the `.mustache` extension (nested folders are also supported). When not set, the tool uses its own set of templates.
135
141
 
136
142
  _Example:_
137
143
 
@@ -139,13 +145,13 @@ _Example:_
139
145
  const { join } = require( 'path' );
140
146
 
141
147
  module.exports = {
142
- templatesPath: join( __dirname, 'plugin-templates' ),
148
+ pluginTemplatesPath: join( __dirname, 'plugin-templates' ),
143
149
  };
144
150
  ```
145
151
 
146
152
  #### `blockTemplatesPath`
147
153
 
148
- An optional field with the path pointing to the location where template files for the individual block live (nested folders are also supported). All files without the `.mustache` extension will be ignored.
154
+ This optional field allows overriding file templates related to **the individual block**. The path points to a location with template files ending with the `.mustache` extension (nested folders are also supported). When not set, the tool uses its own set of templates.
149
155
 
150
156
  _Example:_
151
157
 
@@ -159,7 +165,7 @@ module.exports = {
159
165
 
160
166
  #### `assetsPath`
161
167
 
162
- This setting is useful when your template scaffolds a plugin that uses static assets like images or fonts, which should not be processed. It provides the path pointing to the location where assets are located. They will be copied to the `assets` subfolder in the generated plugin.
168
+ This setting is useful when your template scaffolds a WordPress plugin that uses static assets like images or fonts, which should not be processed. It provides the path pointing to the location where assets are located. They will be copied to the `assets` subfolder in the generated plugin.
163
169
 
164
170
  _Example:_
165
171
 
@@ -185,34 +191,44 @@ module.exports = {
185
191
  dashicon: 'palmtree',
186
192
  version: '1.2.3',
187
193
  },
188
- templatesPath: __dirname,
189
194
  };
190
195
  ```
191
196
 
192
- The following configurable variables are used with the template files. Template authors can change default values to use when users don't provide their data:
193
-
194
- - `$schema` (default: `https://schemas.wp.org/trunk/block.json`)
195
- - `apiVersion` (default: `2`) - see https://make.wordpress.org/core/2020/11/18/block-api-version-2/.
196
- - `slug` (no default)
197
- - `namespace` (default: `'create-block'`)
198
- - `title` (no default) - a display title for your block.
199
- - `description` (no default) - a short description for your block.
200
- - `dashicon` (no default) - an icon property thats makes it easier to identify a block, see https://developer.wordpress.org/resource/dashicons/.
201
- - `category` (default: `'widgets'`) - blocks are grouped into categories to help users browse and discover them. The categories provided by core are `text`, `media`, `design`, `widgets`, `theme`, and `embed`.
202
- - `attributes` (no default) - see https://developer.wordpress.org/block-editor/developers/block-api/block-attributes/.
203
- - `supports` (no default) - optional block extended support features, see https://developer.wordpress.org/block-editor/developers/block-api/block-supports/.
204
- - `author` (default: `'The WordPress Contributors'`)
205
- - `license` (default: `'GPL-2.0-or-later'`)
206
- - `licenseURI` (default: `'https://www.gnu.org/licenses/gpl-2.0.html'`)
207
- - `version` (default: `'0.1.0'`)
208
- - `wpScripts` (default: `true`)
209
- - `wpEnv` (default: `false`) - enables integration with the `@wordpress/env` package and adds the `env` command to the package.json.
197
+ The following configurable variables are used with the template files. Template authors can change default values to use when users don't provide their data.
198
+
199
+ **Project**:
200
+
201
+ - `wpScripts` (default: `true`) – enables integration with the `@wordpress/scripts` package and adds common scripts to the `package.json`.
202
+ - `wpEnv` (default: `false`) – enables integration with the `@wordpress/env` package and adds the `env` script to the `package.json`.
203
+ - `customScripts` (default: {}) the list of custom scripts to add to `package.json` . It also allows overriding default scripts.
210
204
  - `npmDependencies` (default: `[]`) – the list of remote npm packages to be installed in the project with [`npm install`](https://docs.npmjs.com/cli/v8/commands/npm-install) when `wpScripts` is enabled.
211
- `customScripts` (default: {}) - the list of custom scripts to add to `package.json`. It also allows overriding default scripts.
205
+
206
+ **Plugin header fields** ([learn more](https://developer.wordpress.org/plugins/plugin-basics/header-requirements/)):
207
+
208
+ - `pluginURI` (no default) – the home page of the plugin.
209
+ - `version` (default: `'0.1.0'`) – the current version number of the plugin.
210
+ - `author` (default: `'The WordPress Contributors'`) – the name of the plugin author(s).
211
+ - `license` (default: `'GPL-2.0-or-later'`) – the short name of the plugin’s license.
212
+ - `licenseURI` (default: `'https://www.gnu.org/licenses/gpl-2.0.html'`) – a link to the full text of the license.
213
+ - `domainPath` (no default) – a custom domain path for the translations ([more info](https://developer.wordpress.org/plugins/internationalization/how-to-internationalize-your-plugin/#domain-path)).
214
+ - `updateURI:` (no default) – a custom update URI for the plugin ([related dev note](https://make.wordpress.org/core/2021/06/29/introducing-update-uri-plugin-header-in-wordpress-5-8/)).
215
+
216
+ **Block metadata** ([learn more](https://developer.wordpress.org/block-editor/reference-guides/block-api/block-metadata/)):
217
+
212
218
  - `folderName` (default: `.`) – the location for the `block.json` file and other optional block files generated from block templates included in the folder set with the `blockTemplatesPath` setting.
213
- - `editorScript` (default: `'file:./build/index.js'`)
214
- - `editorStyle` (default: `'file:./build/index.css'`)
215
- - `style` (default: `'file:./build/style-index.css'`)
219
+ - `$schema` (default: `https://schemas.wp.org/trunk/block.json`) – the schema URL used for block validation.
220
+ - `apiVersion` (default: `2`) – the block API version ([related dev note](https://make.wordpress.org/core/2020/11/18/block-api-version-2/)).
221
+ - `slug` (no default) – the block slug used for identification in the block name.
222
+ - `namespace` (default: `'create-block'`) – the internal namespace for the block name.
223
+ - `title` (no default) – a display title for your block.
224
+ - `description` (no default) – a short description for your block.
225
+ - `dashicon` (no default) – an icon property thats makes it easier to identify a block ([available values](https://developer.wordpress.org/resource/dashicons/)).
226
+ - `category` (default: `'widgets'`) – blocks are grouped into categories to help users browse and discover them. The categories provided by core are `text`, `media`, `design`, `widgets`, `theme`, and `embed`.
227
+ - `attributes` (no default) – block attributes ([more details](https://developer.wordpress.org/block-editor/developers/block-api/block-attributes/)).
228
+ - `supports` (no default) – optional block extended support features ([more details](https://developer.wordpress.org/block-editor/developers/block-api/block-supports/).
229
+ - `editorScript` (default: `'file:./index.js'`) – an editor script definition.
230
+ - `editorStyle` (default: `'file:./index.css'`) – an editor style definition.
231
+ - `style` (default: `'file:./style-index.css'`) – a frontend and editor style definition.
216
232
 
217
233
  ## Contributing to this package
218
234
 
package/lib/index.js CHANGED
@@ -23,26 +23,29 @@ const commandName = `wp-create-block`;
23
23
  program
24
24
  .name( commandName )
25
25
  .description(
26
- 'Generates PHP, JS and CSS code for registering a block for a WordPress plugin.\n\n' +
27
- '[slug] is optional. When provided it triggers the quick mode where ' +
26
+ 'Generates PHP, JS and CSS code for registering a WordPress plugin with blocks.\n\n' +
27
+ '[slug] is optional. When provided, it triggers the quick mode where ' +
28
28
  'it is used as the block slug used for its identification, the output ' +
29
29
  'location for scaffolded files, and the name of the WordPress plugin.' +
30
30
  'The rest of the configuration is set to all default values unless ' +
31
- 'overridden with some of the options listed below.'
31
+ 'overridden with some options listed below.'
32
32
  )
33
33
  .version( version )
34
34
  .arguments( '[slug]' )
35
35
  .option(
36
36
  '-t, --template <name>',
37
- 'plugin template type name, allowed values: "es5", "esnext", or the name of an external npm package',
38
- 'esnext'
37
+ 'project template type name; allowed values: "static", "es5", the name of an external npm package, or the path to a local directory',
38
+ 'static'
39
39
  )
40
40
  .option( '--namespace <value>', 'internal namespace for the block name' )
41
- .option( '--title <value>', 'display title for the plugin/block' )
41
+ .option(
42
+ '--title <value>',
43
+ 'display title for the block and the WordPress plugin'
44
+ )
42
45
  // The name "description" is used internally so it couldn't be used.
43
46
  .option(
44
47
  '--short-description <value>',
45
- 'short description for the plugin/block'
48
+ 'short description for the block and the WordPress plugin'
46
49
  )
47
50
  .option( '--category <name>', 'category name for the block' )
48
51
  .option(
@@ -93,17 +96,55 @@ program
93
96
  };
94
97
  await scaffold( pluginTemplate, answers );
95
98
  } else {
96
- const prompts = getPrompts( pluginTemplate ).filter(
97
- ( { name } ) =>
98
- ! Object.keys( optionsValues ).includes( name )
99
- );
100
99
  log.info( '' );
101
- log.info( "Let's customize your WordPress plugin:" );
102
- const answers = await inquirer.prompt( prompts );
100
+ log.info(
101
+ "Let's customize your WordPress plugin with blocks:"
102
+ );
103
+
104
+ const filterOptionsProvided = ( { name } ) =>
105
+ ! Object.keys( optionsValues ).includes( name );
106
+ const blockPrompts = getPrompts( pluginTemplate, [
107
+ 'slug',
108
+ 'namespace',
109
+ 'title',
110
+ 'description',
111
+ 'dashicon',
112
+ 'category',
113
+ ] ).filter( filterOptionsProvided );
114
+ const blockAnswers = await inquirer.prompt( blockPrompts );
115
+
116
+ const pluginAnswers = await inquirer
117
+ .prompt( {
118
+ type: 'confirm',
119
+ name: 'configurePlugin',
120
+ message:
121
+ 'Do you want to customize the WordPress plugin?',
122
+ default: false,
123
+ } )
124
+ .then( async ( { configurePlugin } ) => {
125
+ if ( ! configurePlugin ) {
126
+ return {};
127
+ }
128
+
129
+ const pluginPrompts = getPrompts( pluginTemplate, [
130
+ 'pluginURI',
131
+ 'version',
132
+ 'author',
133
+ 'license',
134
+ 'licenseURI',
135
+ 'domainPath',
136
+ 'updateURI',
137
+ ] ).filter( filterOptionsProvided );
138
+ const result = await inquirer.prompt(
139
+ pluginPrompts
140
+ );
141
+ return result;
142
+ } );
103
143
  await scaffold( pluginTemplate, {
104
144
  ...defaultValues,
105
145
  ...optionsValues,
106
- ...answers,
146
+ ...blockAnswers,
147
+ ...pluginAnswers,
107
148
  } );
108
149
  }
109
150
  } catch ( error ) {
@@ -16,6 +16,7 @@ module.exports = async ( {
16
16
  author,
17
17
  description,
18
18
  license,
19
+ pluginURI,
19
20
  slug,
20
21
  version,
21
22
  wpEnv,
@@ -37,6 +38,7 @@ module.exports = async ( {
37
38
  description,
38
39
  author,
39
40
  license,
41
+ homepage: pluginURI,
40
42
  main: wpScripts && 'build/index.js',
41
43
  scripts: {
42
44
  ...( wpScripts && {
package/lib/prompts.js CHANGED
@@ -3,6 +3,7 @@
3
3
  */
4
4
  const { isEmpty, upperFirst } = require( 'lodash' );
5
5
 
6
+ // Block metadata.
6
7
  const slug = {
7
8
  type: 'input',
8
9
  name: 'slug',
@@ -73,6 +74,29 @@ const category = {
73
74
  choices: [ 'text', 'media', 'design', 'widgets', 'theme', 'embed' ],
74
75
  };
75
76
 
77
+ // Plugin header fields.
78
+ const pluginURI = {
79
+ type: 'input',
80
+ name: 'pluginURI',
81
+ message:
82
+ 'The home page of the plugin (optional). Unique URL outside of WordPress.org:',
83
+ };
84
+
85
+ const version = {
86
+ type: 'input',
87
+ name: 'version',
88
+ message: 'The current version number of the plugin:',
89
+ validate( input ) {
90
+ // Regular expression was copied from https://semver.org.
91
+ const validSemVerPattern = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
92
+ if ( ! validSemVerPattern.test( input ) ) {
93
+ return 'Invalid Semantic Version provided. Visit https://regex101.com/r/vkijKf/1/ to discover all valid patterns.';
94
+ }
95
+
96
+ return true;
97
+ },
98
+ };
99
+
76
100
  const author = {
77
101
  type: 'input',
78
102
  name: 'author',
@@ -92,19 +116,16 @@ const licenseURI = {
92
116
  message: 'A link to the full text of the license (optional):',
93
117
  };
94
118
 
95
- const version = {
119
+ const domainPath = {
96
120
  type: 'input',
97
- name: 'version',
98
- message: 'The current version number of the plugin:',
99
- validate( input ) {
100
- // Regular expression was copied from https://semver.org.
101
- const validSemVerPattern = /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/;
102
- if ( ! validSemVerPattern.test( input ) ) {
103
- return 'Invalid Semantic Version provided. Visit https://regex101.com/r/vkijKf/1/ to discover all valid patterns.';
104
- }
121
+ name: 'domainPath',
122
+ message: 'A custom domain path for the translations (optional):',
123
+ };
105
124
 
106
- return true;
107
- },
125
+ const updateURI = {
126
+ type: 'input',
127
+ name: 'updateURI',
128
+ message: 'A custom update URI for the plugin (optional):',
108
129
  };
109
130
 
110
131
  module.exports = {
@@ -114,8 +135,11 @@ module.exports = {
114
135
  description,
115
136
  dashicon,
116
137
  category,
138
+ pluginURI,
139
+ version,
117
140
  author,
118
141
  license,
119
142
  licenseURI,
120
- version,
143
+ domainPath,
144
+ updateURI,
121
145
  };
package/lib/scaffold.js CHANGED
@@ -14,7 +14,7 @@ const { code, info, success } = require( './log' );
14
14
  const { writeOutputAsset, writeOutputTemplate } = require( './output' );
15
15
 
16
16
  module.exports = async (
17
- { blockOutputTemplates, outputTemplates, outputAssets },
17
+ { blockOutputTemplates, pluginOutputTemplates, outputAssets },
18
18
  {
19
19
  $schema,
20
20
  apiVersion,
@@ -27,8 +27,11 @@ module.exports = async (
27
27
  attributes,
28
28
  supports,
29
29
  author,
30
+ pluginURI,
30
31
  license,
31
32
  licenseURI,
33
+ domainPath,
34
+ updateURI,
32
35
  version,
33
36
  wpScripts,
34
37
  wpEnv,
@@ -44,7 +47,7 @@ module.exports = async (
44
47
  namespace = namespace.toLowerCase();
45
48
 
46
49
  info( '' );
47
- info( `Creating a new WordPress plugin in "${ slug }" folder.` );
50
+ info( `Creating a new WordPress plugin in the "${ slug }" directory.` );
48
51
 
49
52
  const view = {
50
53
  $schema,
@@ -62,9 +65,12 @@ module.exports = async (
62
65
  supports,
63
66
  version,
64
67
  author,
68
+ pluginURI,
65
69
  license,
66
70
  licenseURI,
67
71
  textdomain: slug,
72
+ domainPath,
73
+ updateURI,
68
74
  wpScripts,
69
75
  wpEnv,
70
76
  npmDependencies,
@@ -76,10 +82,10 @@ module.exports = async (
76
82
  };
77
83
 
78
84
  await Promise.all(
79
- Object.keys( outputTemplates ).map(
85
+ Object.keys( pluginOutputTemplates ).map(
80
86
  async ( outputFile ) =>
81
87
  await writeOutputTemplate(
82
- outputTemplates[ outputFile ],
88
+ pluginOutputTemplates[ outputFile ],
83
89
  outputFile,
84
90
  view
85
91
  )
@@ -111,11 +117,11 @@ module.exports = async (
111
117
 
112
118
  info( '' );
113
119
  success(
114
- `Done: block "${ title }" bootstrapped in the "${ slug }" folder.`
120
+ `Done: WordPress plugin "${ title }" bootstrapped in the "${ slug }" directory.`
115
121
  );
116
122
  if ( wpScripts ) {
117
123
  info( '' );
118
- info( 'Inside that directory, you can run several commands:' );
124
+ info( 'You can run several commands inside:' );
119
125
  info( '' );
120
126
  code( ' $ npm start' );
121
127
  info( ' Starts the build for development.' );
@@ -132,11 +138,14 @@ module.exports = async (
132
138
  code( ' $ npm run lint:js' );
133
139
  info( ' Lints JavaScript files.' );
134
140
  info( '' );
141
+ code( ' $ npm run plugin-zip' );
142
+ info( ' Creates a zip file for a WordPress plugin.' );
143
+ info( '' );
135
144
  code( ' $ npm run packages-update' );
136
145
  info( ' Updates WordPress packages to the latest version.' );
137
146
  }
138
147
  info( '' );
139
- info( 'To enter the folder type:' );
148
+ info( 'To enter the directory type:' );
140
149
  info( '' );
141
150
  code( ` $ cd ${ slug }` );
142
151
  if ( wpScripts ) {
@@ -30,7 +30,6 @@ registerBlockType( '{{namespace}}/{{slug}}', {
30
30
  * @see ./edit.js
31
31
  */
32
32
  edit: Edit,
33
-
34
33
  /**
35
34
  * @see ./save.js
36
35
  */
@@ -1,6 +1,9 @@
1
1
  <?php
2
2
  /**
3
3
  * Plugin Name: {{title}}
4
+ {{#pluginURI}}
5
+ * Plugin URI: {{{pluginURI}}}
6
+ {{/pluginURI}}
4
7
  {{#description}}
5
8
  * Description: {{description}}
6
9
  {{/description}}
@@ -17,6 +20,12 @@
17
20
  * License URI: {{{licenseURI}}}
18
21
  {{/licenseURI}}
19
22
  * Text Domain: {{textdomain}}
23
+ {{#domainPath}}
24
+ * Domain Path: {{{domainPath}}}
25
+ {{/domainPath}}
26
+ {{#updateURI}}
27
+ * Update URI: {{{updateURI}}}
28
+ {{/updateURI}}
20
29
  *
21
30
  * @package {{namespace}}
22
31
  */
@@ -1,6 +1,9 @@
1
1
  <?php
2
2
  /**
3
3
  * Plugin Name: {{title}}
4
+ {{#pluginURI}}
5
+ * Plugin URI: {{{pluginURI}}}
6
+ {{/pluginURI}}
4
7
  {{#description}}
5
8
  * Description: {{description}}
6
9
  {{/description}}
@@ -17,6 +20,12 @@
17
20
  * License URI: {{{licenseURI}}}
18
21
  {{/licenseURI}}
19
22
  * Text Domain: {{textdomain}}
23
+ {{#domainPath}}
24
+ * Domain Path: {{{domainPath}}}
25
+ {{/domainPath}}
26
+ {{#updateURI}}
27
+ * Update URI: {{{updateURI}}}
28
+ {{/updateURI}}
20
29
  *
21
30
  * @package {{namespace}}
22
31
  */
package/lib/templates.js CHANGED
@@ -22,10 +22,10 @@ const prompts = require( './prompts' );
22
22
  const predefinedPluginTemplates = {
23
23
  es5: {
24
24
  defaultValues: {
25
- slug: 'es5-example',
26
- title: 'ES5 Example',
25
+ slug: 'example-static-es5',
26
+ title: 'Example Static (ES5)',
27
27
  description:
28
- 'Example block written with ES5 standard and no JSX – no build step required.',
28
+ 'Example static block scaffolded with Create Block tool – no build step required.',
29
29
  dashicon: 'smiley',
30
30
  wpScripts: false,
31
31
  editorScript: 'file:./index.js',
@@ -34,23 +34,17 @@ const predefinedPluginTemplates = {
34
34
  },
35
35
  templatesPath: join( __dirname, 'templates', 'es5' ),
36
36
  },
37
- esnext: {
37
+ static: {
38
38
  defaultValues: {
39
- slug: 'esnext-example',
40
- title: 'ESNext Example',
39
+ slug: 'example-static',
40
+ title: 'Example Static',
41
41
  description:
42
- 'Example block written with ESNext standard and JSX support – build step required.',
42
+ 'Example static block scaffolded with Create Block tool.',
43
43
  dashicon: 'smiley',
44
44
  supports: {
45
45
  html: false,
46
46
  },
47
- folderName: 'src',
48
- editorScript: 'file:./index.js',
49
- editorStyle: 'file:./index.css',
50
- style: 'file:./style-index.css',
51
47
  },
52
- templatesPath: join( __dirname, 'templates', 'esnext', 'plugin' ),
53
- blockTemplatesPath: join( __dirname, 'templates', 'esnext', 'block' ),
54
48
  },
55
49
  };
56
50
 
@@ -103,22 +97,39 @@ const externalTemplateExists = async ( templateName ) => {
103
97
  };
104
98
 
105
99
  const configToTemplate = async ( {
106
- assetsPath,
100
+ pluginTemplatesPath,
107
101
  blockTemplatesPath,
108
102
  defaultValues = {},
109
- templatesPath,
103
+ assetsPath,
104
+ ...deprecated
110
105
  } ) => {
111
- if ( ! isObject( defaultValues ) || ! templatesPath ) {
106
+ if ( ! isObject( defaultValues ) ) {
112
107
  throw new CLIError( 'Template found but invalid definition provided.' );
113
108
  }
114
109
 
110
+ if ( deprecated.templatesPath ) {
111
+ pluginTemplatesPath = deprecated.templatesPath;
112
+ defaultValues = {
113
+ folderName: '.',
114
+ editorScript: 'file:./build/index.js',
115
+ editorStyle: 'file:./build/index.css',
116
+ style: 'file:./build/style-index.css',
117
+ ...defaultValues,
118
+ };
119
+ } else {
120
+ pluginTemplatesPath =
121
+ pluginTemplatesPath || join( __dirname, 'templates', 'plugin' );
122
+ blockTemplatesPath =
123
+ blockTemplatesPath || join( __dirname, 'templates', 'block' );
124
+ }
125
+
115
126
  return {
116
127
  blockOutputTemplates: blockTemplatesPath
117
128
  ? await getOutputTemplates( blockTemplatesPath )
118
129
  : {},
119
130
  defaultValues,
120
131
  outputAssets: assetsPath ? await getOutputAssets( assetsPath ) : {},
121
- outputTemplates: await getOutputTemplates( templatesPath ),
132
+ pluginOutputTemplates: await getOutputTemplates( pluginTemplatesPath ),
122
133
  };
123
134
  };
124
135
 
@@ -201,17 +212,17 @@ const getDefaultValues = ( pluginTemplate ) => {
201
212
  customScripts: {},
202
213
  wpEnv: false,
203
214
  npmDependencies: [],
204
- folderName: '.',
205
- editorScript: 'file:./build/index.js',
206
- editorStyle: 'file:./build/index.css',
207
- style: 'file:./build/style-index.css',
215
+ folderName: './src',
216
+ editorScript: 'file:./index.js',
217
+ editorStyle: 'file:./index.css',
218
+ style: 'file:./style-index.css',
208
219
  ...pluginTemplate.defaultValues,
209
220
  };
210
221
  };
211
222
 
212
- const getPrompts = ( pluginTemplate ) => {
223
+ const getPrompts = ( pluginTemplate, keys ) => {
213
224
  const defaultValues = getDefaultValues( pluginTemplate );
214
- return Object.keys( prompts ).map( ( promptName ) => {
225
+ return keys.map( ( promptName ) => {
215
226
  return {
216
227
  ...prompts[ promptName ],
217
228
  default: defaultValues[ promptName ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/create-block",
3
- "version": "2.9.1-next.f435e9e01b.0",
3
+ "version": "3.1.0-next.e230fbab09.0",
4
4
  "description": "Generates PHP, JS and CSS code for registering a block for a WordPress plugin.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -31,7 +31,7 @@
31
31
  "wp-create-block": "./index.js"
32
32
  },
33
33
  "dependencies": {
34
- "@wordpress/lazy-import": "^1.4.1-next.f435e9e01b.0",
34
+ "@wordpress/lazy-import": "^1.5.0-next.e230fbab09.0",
35
35
  "chalk": "^4.0.0",
36
36
  "check-node-version": "^4.1.0",
37
37
  "commander": "^4.1.0",
@@ -48,5 +48,5 @@
48
48
  "publishConfig": {
49
49
  "access": "public"
50
50
  },
51
- "gitHead": "14b2846015dfb1b440ce93accdd03842ebe5f1cd"
51
+ "gitHead": "308df03e6a96ded732f9c4e32471b1b4f8dea54a"
52
52
  }