@wordpress/create-block 2.7.2-next.33ec3857e2.0 → 2.9.1-next.f435e9e01b.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,7 +2,25 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- ## 2.7.1-next.0 (2021-12-20)
5
+ ## 2.9.0-next.0 (2022-02-23)
6
+
7
+ ### New Features
8
+
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)).
11
+
12
+ ## 2.8.0 (2022-01-27)
13
+
14
+ ### New Features
15
+
16
+ - Integrated a new `plugin-zip` command to create a zip file for a WordPress plugin ([#37687](https://github.com/WordPress/gutenberg/pull/37687)).
17
+ - Add support for handling block templates with the `blockTemplatesPath` field in the external template configuration ([#37612](https://github.com/WordPress/gutenberg/pull/37612)).
18
+ - Add a new field `folderName` for setting 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 ([#37612](https://github.com/WordPress/gutenberg/pull/37612)).
19
+
20
+ ### Enhancement
21
+
22
+ - Speed up scaffolding process by omitting WordPress dependencies in the template ([#37639](https://github.com/WordPress/gutenberg/pull/37639)).
23
+ - Update link to block registration reference ([#37674](https://github.com/WordPress/gutenberg/pull/37674))
6
24
 
7
25
  ### Internal
8
26
 
package/LICENSE.md CHANGED
@@ -1,6 +1,6 @@
1
1
  ## Gutenberg
2
2
 
3
- Copyright 2016-2021 by the contributors
3
+ Copyright 2016-2022 by the contributors
4
4
 
5
5
  **License for Contributions (on and after April 15, 2021)**
6
6
 
package/README.md CHANGED
@@ -12,7 +12,7 @@ Visit the [Gutenberg handbook](https://developer.wordpress.org/block-editor/deve
12
12
 
13
13
  ## Quick start
14
14
 
15
- You just need to provide the `slug` which is the target location for scaffolded files and the internal block name.
15
+ You just need to provide the `slug` which is 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
@@ -40,10 +40,10 @@ Options:
40
40
 
41
41
  ```bash
42
42
  -V, --version output the version number
43
- -t, --template <name> block 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> plugin template type name, allowed values: "es5", "esnext", the name of an external npm package (default: "esnext"), or the path to a local directory.
44
44
  --namespace <value> internal namespace for the block name
45
- --title <value> display title for the block
46
- --short-description <value> short description for the block
45
+ --title <value> display title for the plugin/block
46
+ --short-description <value> short description for the plugin/block
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
@@ -87,37 +87,37 @@ When bootstrapped with the `esnext` template (or any external template with `wpS
87
87
  $ npm start
88
88
  ```
89
89
 
90
- Starts the build for development. [Learn more](/packages/scripts#start).
90
+ Starts the build for development. [Learn more](https://github.com/WordPress/gutenberg/tree/HEAD/packages/scripts#start).
91
91
 
92
92
  ```bash
93
93
  $ npm run build
94
94
  ```
95
95
 
96
- Builds the code for production. [Learn more](/packages/scripts#build).
96
+ Builds the code for production. [Learn more](https://github.com/WordPress/gutenberg/tree/HEAD/packages/scripts#build).
97
97
 
98
98
  ```bash
99
99
  $ npm run format
100
100
  ```
101
101
 
102
- Formats files. [Learn more](/packages/scripts#format).
102
+ Formats files. [Learn more](https://github.com/WordPress/gutenberg/tree/HEAD/packages/scripts#format).
103
103
 
104
104
  ```bash
105
105
  $ npm run lint:css
106
106
  ```
107
107
 
108
- Lints CSS files. [Learn more](/packages/scripts#lint-style).
108
+ Lints CSS files. [Learn more](https://github.com/WordPress/gutenberg/tree/HEAD/packages/scripts#lint-style).
109
109
 
110
110
  ```bash
111
111
  $ npm run lint:js
112
112
  ```
113
113
 
114
- Lints JavaScript files. [Learn more](/packages/scripts#lint-js).
114
+ Lints JavaScript files. [Learn more](https://github.com/WordPress/gutenberg/tree/HEAD/packages/scripts#lint-js).
115
115
 
116
116
  ```bash
117
117
  $ npm run packages-update
118
118
  ```
119
119
 
120
- Updates WordPress packages to the latest version. [Learn more](/packages/scripts#packages-update).
120
+ Updates WordPress packages to the latest version. [Learn more](https://github.com/WordPress/gutenberg/tree/HEAD/packages/scripts#packages-update).
121
121
 
122
122
  _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
123
 
@@ -131,7 +131,7 @@ It is mandatory to provide the main file (`index.js` by default) for the package
131
131
 
132
132
  #### `templatesPath`
133
133
 
134
- A mandatory field with the path pointing to the location where template files live (nested folders are also supported). All files without the `.mustache` extension will be ignored.
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.
135
135
 
136
136
  _Example:_
137
137
 
@@ -139,13 +139,27 @@ _Example:_
139
139
  const { join } = require( 'path' );
140
140
 
141
141
  module.exports = {
142
- templatesPath: join( __dirname, 'templates' ),
142
+ templatesPath: join( __dirname, 'plugin-templates' ),
143
+ };
144
+ ```
145
+
146
+ #### `blockTemplatesPath`
147
+
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.
149
+
150
+ _Example:_
151
+
152
+ ```js
153
+ const { join } = require( 'path' );
154
+
155
+ module.exports = {
156
+ blockTemplatesPath: join( __dirname, 'block-templates' ),
143
157
  };
144
158
  ```
145
159
 
146
160
  #### `assetsPath`
147
161
 
148
- This setting is useful when your template scaffolds a block 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.
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.
149
163
 
150
164
  _Example:_
151
165
 
@@ -153,7 +167,7 @@ _Example:_
153
167
  const { join } = require( 'path' );
154
168
 
155
169
  module.exports = {
156
- assetsPath: join( __dirname, 'assets' ),
170
+ assetsPath: join( __dirname, 'plugin-assets' ),
157
171
  };
158
172
  ```
159
173
 
@@ -192,10 +206,18 @@ The following configurable variables are used with the template files. Template
192
206
  - `licenseURI` (default: `'https://www.gnu.org/licenses/gpl-2.0.html'`)
193
207
  - `version` (default: `'0.1.0'`)
194
208
  - `wpScripts` (default: `true`)
195
- - `wpEnv` (default: `false`)
196
- - `npmDependencies` (default: `[]`) – the list of remote npm packages to be installed in the project with [`npm install`](https://docs.npmjs.com/cli/v6/commands/npm-install).
209
+ - `wpEnv` (default: `false`) - enables integration with the `@wordpress/env` package and adds the `env` command to the package.json.
210
+ - `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.
212
+ - `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.
197
213
  - `editorScript` (default: `'file:./build/index.js'`)
198
214
  - `editorStyle` (default: `'file:./build/index.css'`)
199
215
  - `style` (default: `'file:./build/style-index.css'`)
200
216
 
201
- <br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
217
+ ## Contributing to this package
218
+
219
+ This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects.
220
+
221
+ To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).
222
+
223
+ <br /><br /><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
package/lib/index.js CHANGED
@@ -14,7 +14,7 @@ const log = require( './log' );
14
14
  const { engines, version } = require( '../package.json' );
15
15
  const scaffold = require( './scaffold' );
16
16
  const {
17
- getBlockTemplate,
17
+ getPluginTemplate,
18
18
  getDefaultValues,
19
19
  getPrompts,
20
20
  } = require( './templates' );
@@ -34,13 +34,16 @@ program
34
34
  .arguments( '[slug]' )
35
35
  .option(
36
36
  '-t, --template <name>',
37
- 'block template type name, allowed values: "es5", "esnext", or the name of an external npm package',
37
+ 'plugin template type name, allowed values: "es5", "esnext", or the name of an external npm package',
38
38
  'esnext'
39
39
  )
40
40
  .option( '--namespace <value>', 'internal namespace for the block name' )
41
- .option( '--title <value>', 'display title for the block' )
41
+ .option( '--title <value>', 'display title for the plugin/block' )
42
42
  // The name "description" is used internally so it couldn't be used.
43
- .option( '--short-description <value>', 'short description for the block' )
43
+ .option(
44
+ '--short-description <value>',
45
+ 'short description for the plugin/block'
46
+ )
44
47
  .option( '--category <name>', 'category name for the block' )
45
48
  .option(
46
49
  '--wp-scripts',
@@ -66,8 +69,8 @@ program
66
69
  ) => {
67
70
  await checkSystemRequirements( engines );
68
71
  try {
69
- const blockTemplate = await getBlockTemplate( templateName );
70
- const defaultValues = getDefaultValues( blockTemplate );
72
+ const pluginTemplate = await getPluginTemplate( templateName );
73
+ const defaultValues = getDefaultValues( pluginTemplate );
71
74
  const optionsValues = pickBy(
72
75
  {
73
76
  category,
@@ -88,16 +91,16 @@ program
88
91
  title: startCase( slug ),
89
92
  ...optionsValues,
90
93
  };
91
- await scaffold( blockTemplate, answers );
94
+ await scaffold( pluginTemplate, answers );
92
95
  } else {
93
- const prompts = getPrompts( blockTemplate ).filter(
96
+ const prompts = getPrompts( pluginTemplate ).filter(
94
97
  ( { name } ) =>
95
98
  ! Object.keys( optionsValues ).includes( name )
96
99
  );
97
100
  log.info( '' );
98
- log.info( "Let's customize your block:" );
101
+ log.info( "Let's customize your WordPress plugin:" );
99
102
  const answers = await inquirer.prompt( prompts );
100
- await scaffold( blockTemplate, {
103
+ await scaffold( pluginTemplate, {
101
104
  ...defaultValues,
102
105
  ...optionsValues,
103
106
  ...answers,
@@ -2,15 +2,17 @@
2
2
  * External dependencies
3
3
  */
4
4
  const { omitBy } = require( 'lodash' );
5
- const { join } = require( 'path' );
5
+ const { dirname, join } = require( 'path' );
6
+ const makeDir = require( 'make-dir' );
6
7
  const { writeFile } = require( 'fs' ).promises;
7
8
 
8
9
  /**
9
10
  * Internal dependencies
10
11
  */
11
12
  const { info } = require( './log' );
13
+ const { writeOutputTemplate } = require( './output' );
12
14
 
13
- module.exports = async ( {
15
+ async function initBlockJSON( {
14
16
  $schema,
15
17
  apiVersion,
16
18
  slug,
@@ -23,13 +25,16 @@ module.exports = async ( {
23
25
  supports,
24
26
  dashicon,
25
27
  textdomain,
28
+ folderName,
26
29
  editorScript,
27
30
  editorStyle,
28
31
  style,
29
- } ) => {
30
- const outputFile = join( process.cwd(), slug, 'block.json' );
32
+ } ) {
31
33
  info( '' );
32
34
  info( 'Creating a "block.json" file.' );
35
+
36
+ const outputFile = join( process.cwd(), slug, folderName, 'block.json' );
37
+ await makeDir( dirname( outputFile ) );
33
38
  await writeFile(
34
39
  outputFile,
35
40
  JSON.stringify(
@@ -56,4 +61,19 @@ module.exports = async ( {
56
61
  '\t'
57
62
  )
58
63
  );
64
+ }
65
+
66
+ module.exports = async function ( outputTemplates, view ) {
67
+ await Promise.all(
68
+ Object.keys( outputTemplates ).map(
69
+ async ( outputFile ) =>
70
+ await writeOutputTemplate(
71
+ outputTemplates[ outputFile ],
72
+ join( view.folderName, outputFile ),
73
+ view
74
+ )
75
+ )
76
+ );
77
+
78
+ await initBlockJSON( view );
59
79
  };
@@ -18,13 +18,16 @@ module.exports = async ( {
18
18
  license,
19
19
  slug,
20
20
  version,
21
+ wpEnv,
21
22
  wpScripts,
22
23
  npmDependencies,
24
+ customScripts,
23
25
  } ) => {
24
26
  const cwd = join( process.cwd(), slug );
25
27
 
26
28
  info( '' );
27
29
  info( 'Creating a "package.json" file.' );
30
+
28
31
  await writePkg(
29
32
  cwd,
30
33
  omitBy(
@@ -35,20 +38,25 @@ module.exports = async ( {
35
38
  author,
36
39
  license,
37
40
  main: wpScripts && 'build/index.js',
38
- scripts: wpScripts && {
39
- build: 'wp-scripts build',
40
- format: 'wp-scripts format',
41
- 'lint:css': 'wp-scripts lint-style',
42
- 'lint:js': 'wp-scripts lint-js',
43
- start: 'wp-scripts start',
44
- 'packages-update': 'wp-scripts packages-update',
41
+ scripts: {
42
+ ...( wpScripts && {
43
+ build: 'wp-scripts build',
44
+ format: 'wp-scripts format',
45
+ 'lint:css': 'wp-scripts lint-style',
46
+ 'lint:js': 'wp-scripts lint-js',
47
+ 'packages-update': 'wp-scripts packages-update',
48
+ 'plugin-zip': 'wp-scripts plugin-zip',
49
+ start: 'wp-scripts start',
50
+ } ),
51
+ ...( wpEnv && { env: 'wp-env' } ),
52
+ ...customScripts,
45
53
  },
46
54
  },
47
55
  isEmpty
48
56
  )
49
57
  );
50
58
 
51
- if ( size( npmDependencies ) ) {
59
+ if ( wpScripts && size( npmDependencies ) ) {
52
60
  info( '' );
53
61
  info(
54
62
  'Installing npm dependencies. It might take a couple of minutes...'
package/lib/output.js ADDED
@@ -0,0 +1,28 @@
1
+ /**
2
+ * External dependencies
3
+ */
4
+ const { dirname, join } = require( 'path' );
5
+ const makeDir = require( 'make-dir' );
6
+ const { render } = require( 'mustache' );
7
+ const { writeFile } = require( 'fs' ).promises;
8
+
9
+ const writeOutputAsset = async ( inputFile, outputFile, view ) => {
10
+ const outputFilePath = join( view.slug, 'assets', outputFile );
11
+ await makeDir( dirname( outputFilePath ) );
12
+ writeFile( outputFilePath, inputFile );
13
+ };
14
+
15
+ const writeOutputTemplate = async ( inputFile, outputFile, view ) => {
16
+ // Output files can have names that depend on the slug provided.
17
+ const outputFilePath = join(
18
+ view.slug,
19
+ outputFile.replace( /\$slug/g, view.slug )
20
+ );
21
+ await makeDir( dirname( outputFilePath ) );
22
+ writeFile( outputFilePath, render( inputFile, view ) );
23
+ };
24
+
25
+ module.exports = {
26
+ writeOutputAsset,
27
+ writeOutputTemplate,
28
+ };
package/lib/scaffold.js CHANGED
@@ -1,23 +1,20 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- const { writeFile } = require( 'fs' ).promises;
5
4
  const { snakeCase, camelCase, upperFirst } = require( 'lodash' );
6
- const makeDir = require( 'make-dir' );
7
- const { render } = require( 'mustache' );
8
- const { dirname, join } = require( 'path' );
9
5
 
10
6
  /**
11
7
  * Internal dependencies
12
8
  */
13
- const initBlockJSON = require( './init-block-json' );
9
+ const initBlock = require( './init-block' );
14
10
  const initPackageJSON = require( './init-package-json' );
15
11
  const initWPScripts = require( './init-wp-scripts' );
16
12
  const initWPEnv = require( './init-wp-env' );
17
13
  const { code, info, success } = require( './log' );
14
+ const { writeOutputAsset, writeOutputTemplate } = require( './output' );
18
15
 
19
16
  module.exports = async (
20
- blockTemplate,
17
+ { blockOutputTemplates, outputTemplates, outputAssets },
21
18
  {
22
19
  $schema,
23
20
  apiVersion,
@@ -36,6 +33,8 @@ module.exports = async (
36
33
  wpScripts,
37
34
  wpEnv,
38
35
  npmDependencies,
36
+ customScripts,
37
+ folderName,
39
38
  editorScript,
40
39
  editorStyle,
41
40
  style,
@@ -45,9 +44,8 @@ module.exports = async (
45
44
  namespace = namespace.toLowerCase();
46
45
 
47
46
  info( '' );
48
- info( `Creating a new WordPress block in "${ slug }" folder.` );
47
+ info( `Creating a new WordPress plugin in "${ slug }" folder.` );
49
48
 
50
- const { outputTemplates, outputAssets } = blockTemplate;
51
49
  const view = {
52
50
  $schema,
53
51
  apiVersion,
@@ -68,35 +66,39 @@ module.exports = async (
68
66
  licenseURI,
69
67
  textdomain: slug,
70
68
  wpScripts,
69
+ wpEnv,
71
70
  npmDependencies,
71
+ customScripts,
72
+ folderName,
72
73
  editorScript,
73
74
  editorStyle,
74
75
  style,
75
76
  };
77
+
76
78
  await Promise.all(
77
- Object.keys( outputTemplates ).map( async ( outputFile ) => {
78
- // Output files can have names that depend on the slug provided.
79
- const outputFilePath = join(
80
- slug,
81
- outputFile.replace( /\$slug/g, slug )
82
- );
83
- await makeDir( dirname( outputFilePath ) );
84
- writeFile(
85
- outputFilePath,
86
- render( outputTemplates[ outputFile ], view )
87
- );
88
- } )
79
+ Object.keys( outputTemplates ).map(
80
+ async ( outputFile ) =>
81
+ await writeOutputTemplate(
82
+ outputTemplates[ outputFile ],
83
+ outputFile,
84
+ view
85
+ )
86
+ )
89
87
  );
90
88
 
91
89
  await Promise.all(
92
- Object.keys( outputAssets ).map( async ( outputFile ) => {
93
- const outputFilePath = join( slug, 'assets', outputFile );
94
- await makeDir( dirname( outputFilePath ) );
95
- writeFile( outputFilePath, outputAssets[ outputFile ] );
96
- } )
90
+ Object.keys( outputAssets ).map(
91
+ async ( outputFile ) =>
92
+ await writeOutputAsset(
93
+ outputAssets[ outputFile ],
94
+ outputFile,
95
+ view
96
+ )
97
+ )
97
98
  );
98
99
 
99
- await initBlockJSON( view );
100
+ await initBlock( blockOutputTemplates, view );
101
+
100
102
  await initPackageJSON( view );
101
103
 
102
104
  if ( wpScripts ) {
@@ -3,7 +3,7 @@
3
3
  Contributors: {{author}}
4
4
  {{/author}}
5
5
  Tags: block
6
- Tested up to: 5.8.0
6
+ Tested up to: 5.9
7
7
  Stable tag: {{version}}
8
8
  {{#license}}
9
9
  License: {{license}}
@@ -26,9 +26,9 @@
26
26
  * Behind the scenes, it registers also all assets so they can be enqueued
27
27
  * through the block editor in the corresponding context.
28
28
  *
29
- * @see https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/writing-your-first-block-type/
29
+ * @see https://developer.wordpress.org/reference/functions/register_block_type/
30
30
  */
31
31
  function {{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init() {
32
- register_block_type( __DIR__ );
32
+ register_block_type( __DIR__ . '/build' );
33
33
  }
34
34
  add_action( 'init', '{{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init' );
@@ -20,8 +20,11 @@ node_modules/
20
20
  # Optional eslint cache
21
21
  .eslintcache
22
22
 
23
- # Output of 'npm pack'
23
+ # Output of `npm pack`
24
24
  *.tgz
25
25
 
26
+ # Output of `wp-scripts plugin-zip`
27
+ *.zip
28
+
26
29
  # dotenv environment variables file
27
30
  .env
@@ -3,7 +3,7 @@
3
3
  Contributors: {{author}}
4
4
  {{/author}}
5
5
  Tags: block
6
- Tested up to: 5.8.0
6
+ Tested up to: 5.9
7
7
  Stable tag: {{version}}
8
8
  {{#license}}
9
9
  License: {{license}}
package/lib/templates.js CHANGED
@@ -19,7 +19,7 @@ const CLIError = require( './cli-error' );
19
19
  const { info } = require( './log' );
20
20
  const prompts = require( './prompts' );
21
21
 
22
- const predefinedBlockTemplates = {
22
+ const predefinedPluginTemplates = {
23
23
  es5: {
24
24
  defaultValues: {
25
25
  slug: 'es5-example',
@@ -44,13 +44,13 @@ const predefinedBlockTemplates = {
44
44
  supports: {
45
45
  html: false,
46
46
  },
47
- npmDependencies: [
48
- '@wordpress/block-editor',
49
- '@wordpress/blocks',
50
- '@wordpress/i18n',
51
- ],
47
+ folderName: 'src',
48
+ editorScript: 'file:./index.js',
49
+ editorStyle: 'file:./index.css',
50
+ style: 'file:./style-index.css',
52
51
  },
53
- templatesPath: join( __dirname, 'templates', 'esnext' ),
52
+ templatesPath: join( __dirname, 'templates', 'esnext', 'plugin' ),
53
+ blockTemplatesPath: join( __dirname, 'templates', 'esnext', 'block' ),
54
54
  },
55
55
  };
56
56
 
@@ -104,6 +104,7 @@ const externalTemplateExists = async ( templateName ) => {
104
104
 
105
105
  const configToTemplate = async ( {
106
106
  assetsPath,
107
+ blockTemplatesPath,
107
108
  defaultValues = {},
108
109
  templatesPath,
109
110
  } ) => {
@@ -112,16 +113,19 @@ const configToTemplate = async ( {
112
113
  }
113
114
 
114
115
  return {
116
+ blockOutputTemplates: blockTemplatesPath
117
+ ? await getOutputTemplates( blockTemplatesPath )
118
+ : {},
115
119
  defaultValues,
116
120
  outputAssets: assetsPath ? await getOutputAssets( assetsPath ) : {},
117
121
  outputTemplates: await getOutputTemplates( templatesPath ),
118
122
  };
119
123
  };
120
124
 
121
- const getBlockTemplate = async ( templateName ) => {
122
- if ( predefinedBlockTemplates[ templateName ] ) {
125
+ const getPluginTemplate = async ( templateName ) => {
126
+ if ( predefinedPluginTemplates[ templateName ] ) {
123
127
  return await configToTemplate(
124
- predefinedBlockTemplates[ templateName ]
128
+ predefinedPluginTemplates[ templateName ]
125
129
  );
126
130
  }
127
131
 
@@ -142,8 +146,8 @@ const getBlockTemplate = async ( templateName ) => {
142
146
 
143
147
  if ( ! ( await externalTemplateExists( templateName ) ) ) {
144
148
  throw new CLIError(
145
- `Invalid block template type name: "${ templateName }". Allowed values: ` +
146
- Object.keys( predefinedBlockTemplates )
149
+ `Invalid plugin template type name: "${ templateName }". Allowed values: ` +
150
+ Object.keys( predefinedPluginTemplates )
147
151
  .map( ( name ) => `"${ name }"` )
148
152
  .join( ', ' ) +
149
153
  ', or an existing npm package name.'
@@ -173,7 +177,7 @@ const getBlockTemplate = async ( templateName ) => {
173
177
  throw error;
174
178
  } else {
175
179
  throw new CLIError(
176
- `Invalid block template downloaded. Error: ${ error.message }`
180
+ `Invalid plugin template downloaded. Error: ${ error.message }`
177
181
  );
178
182
  }
179
183
  } finally {
@@ -183,7 +187,7 @@ const getBlockTemplate = async ( templateName ) => {
183
187
  }
184
188
  };
185
189
 
186
- const getDefaultValues = ( blockTemplate ) => {
190
+ const getDefaultValues = ( pluginTemplate ) => {
187
191
  return {
188
192
  $schema: 'https://schemas.wp.org/trunk/block.json',
189
193
  apiVersion: 2,
@@ -194,17 +198,19 @@ const getDefaultValues = ( blockTemplate ) => {
194
198
  licenseURI: 'https://www.gnu.org/licenses/gpl-2.0.html',
195
199
  version: '0.1.0',
196
200
  wpScripts: true,
201
+ customScripts: {},
197
202
  wpEnv: false,
198
203
  npmDependencies: [],
204
+ folderName: '.',
199
205
  editorScript: 'file:./build/index.js',
200
206
  editorStyle: 'file:./build/index.css',
201
207
  style: 'file:./build/style-index.css',
202
- ...blockTemplate.defaultValues,
208
+ ...pluginTemplate.defaultValues,
203
209
  };
204
210
  };
205
211
 
206
- const getPrompts = ( blockTemplate ) => {
207
- const defaultValues = getDefaultValues( blockTemplate );
212
+ const getPrompts = ( pluginTemplate ) => {
213
+ const defaultValues = getDefaultValues( pluginTemplate );
208
214
  return Object.keys( prompts ).map( ( promptName ) => {
209
215
  return {
210
216
  ...prompts[ promptName ],
@@ -214,7 +220,7 @@ const getPrompts = ( blockTemplate ) => {
214
220
  };
215
221
 
216
222
  module.exports = {
217
- getBlockTemplate,
223
+ getPluginTemplate,
218
224
  getDefaultValues,
219
225
  getPrompts,
220
226
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/create-block",
3
- "version": "2.7.2-next.33ec3857e2.0",
3
+ "version": "2.9.1-next.f435e9e01b.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.3.4-next.33ec3857e2.0",
34
+ "@wordpress/lazy-import": "^1.4.1-next.f435e9e01b.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": "51c7917ea7fac72953702f24d6daac87d99e7617"
51
+ "gitHead": "14b2846015dfb1b440ce93accdd03842ebe5f1cd"
52
52
  }