@wordpress/create-block 2.5.1 → 2.7.2-next.33ec3857e2.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,6 +2,25 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 2.7.1-next.0 (2021-12-20)
|
|
6
|
+
|
|
7
|
+
### Internal
|
|
8
|
+
|
|
9
|
+
- The bundled `npm-package-arg` dependency has been updated from requiring `^8.0.1` to requiring `^8.1.5` ([#37395](https://github.com/WordPress/gutenberg/pull/37395)).
|
|
10
|
+
|
|
11
|
+
## 2.7.0 (2021-11-07)
|
|
12
|
+
|
|
13
|
+
### New Features
|
|
14
|
+
|
|
15
|
+
- Add $schema definition to generated `block.json` file.
|
|
16
|
+
|
|
17
|
+
## 2.6.0 (2021-10-22)
|
|
18
|
+
|
|
19
|
+
### New Features
|
|
20
|
+
|
|
21
|
+
- Add passing local directories to --template. ([#35645](https://github.com/WordPress/gutenberg/pull/35645))
|
|
22
|
+
- Add `slugPascalCase` to the list of variables that can be used in templates ([#35462](https://github.com/WordPress/gutenberg/pull/35462))
|
|
23
|
+
|
|
5
24
|
## 2.5.0 (2021-07-21)
|
|
6
25
|
|
|
7
26
|
### Enhancements
|
package/README.md
CHANGED
|
@@ -40,7 +40,7 @@ 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",
|
|
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.
|
|
44
44
|
--namespace <value> internal namespace for the block name
|
|
45
45
|
--title <value> display title for the block
|
|
46
46
|
--short-description <value> short description for the block
|
|
@@ -65,7 +65,13 @@ $ npx @wordpress/create-block
|
|
|
65
65
|
$ npx @wordpress/create-block --template es5
|
|
66
66
|
```
|
|
67
67
|
|
|
68
|
-
3.
|
|
68
|
+
3. Local template directory – it is also possible to pick a local directory as a template.
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
$ npx @wordpress/create-block --template ./path/to/template
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
4. Help – you need to use `npx` to output usage information.
|
|
69
75
|
|
|
70
76
|
```bash
|
|
71
77
|
$ npx @wordpress/create-block --help
|
|
@@ -171,6 +177,7 @@ module.exports = {
|
|
|
171
177
|
|
|
172
178
|
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:
|
|
173
179
|
|
|
180
|
+
- `$schema` (default: `https://schemas.wp.org/trunk/block.json`)
|
|
174
181
|
- `apiVersion` (default: `2`) - see https://make.wordpress.org/core/2020/11/18/block-api-version-2/.
|
|
175
182
|
- `slug` (no default)
|
|
176
183
|
- `namespace` (default: `'create-block'`)
|
|
@@ -191,8 +198,4 @@ The following configurable variables are used with the template files. Template
|
|
|
191
198
|
- `editorStyle` (default: `'file:./build/index.css'`)
|
|
192
199
|
- `style` (default: `'file:./build/style-index.css'`)
|
|
193
200
|
|
|
194
|
-
## WP-CLI
|
|
195
|
-
|
|
196
|
-
Another way of making a developer’s life easier is to use [WP-CLI](https://wp-cli.org), which provides a command-line interface for many actions you might perform on the WordPress instance. One of the commands `wp scaffold block` was used as the baseline for this tool and ES5 template in particular.
|
|
197
|
-
|
|
198
201
|
<br/><br/><p align="center"><img src="https://s.w.org/style/images/codeispoetry.png?1" alt="Code is Poetry." /></p>
|
package/lib/init-block-json.js
CHANGED
|
@@ -11,6 +11,7 @@ const { writeFile } = require( 'fs' ).promises;
|
|
|
11
11
|
const { info } = require( './log' );
|
|
12
12
|
|
|
13
13
|
module.exports = async ( {
|
|
14
|
+
$schema,
|
|
14
15
|
apiVersion,
|
|
15
16
|
slug,
|
|
16
17
|
namespace,
|
|
@@ -34,6 +35,7 @@ module.exports = async ( {
|
|
|
34
35
|
JSON.stringify(
|
|
35
36
|
omitBy(
|
|
36
37
|
{
|
|
38
|
+
$schema,
|
|
37
39
|
apiVersion,
|
|
38
40
|
name: namespace + '/' + slug,
|
|
39
41
|
version,
|
package/lib/scaffold.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* External dependencies
|
|
3
3
|
*/
|
|
4
4
|
const { writeFile } = require( 'fs' ).promises;
|
|
5
|
-
const { snakeCase } = require( 'lodash' );
|
|
5
|
+
const { snakeCase, camelCase, upperFirst } = require( 'lodash' );
|
|
6
6
|
const makeDir = require( 'make-dir' );
|
|
7
7
|
const { render } = require( 'mustache' );
|
|
8
8
|
const { dirname, join } = require( 'path' );
|
|
@@ -19,6 +19,7 @@ const { code, info, success } = require( './log' );
|
|
|
19
19
|
module.exports = async (
|
|
20
20
|
blockTemplate,
|
|
21
21
|
{
|
|
22
|
+
$schema,
|
|
22
23
|
apiVersion,
|
|
23
24
|
namespace,
|
|
24
25
|
slug,
|
|
@@ -48,11 +49,13 @@ module.exports = async (
|
|
|
48
49
|
|
|
49
50
|
const { outputTemplates, outputAssets } = blockTemplate;
|
|
50
51
|
const view = {
|
|
52
|
+
$schema,
|
|
51
53
|
apiVersion,
|
|
52
54
|
namespace,
|
|
53
55
|
namespaceSnakeCase: snakeCase( namespace ),
|
|
54
56
|
slug,
|
|
55
57
|
slugSnakeCase: snakeCase( slug ),
|
|
58
|
+
slugPascalCase: upperFirst( camelCase( slug ) ),
|
|
56
59
|
title,
|
|
57
60
|
description,
|
|
58
61
|
dashicon,
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
* Registers all block assets so that they can be enqueued through the block editor
|
|
26
26
|
* in the corresponding context.
|
|
27
27
|
*
|
|
28
|
-
* @see https://developer.wordpress.org/block-editor/
|
|
28
|
+
* @see https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/applying-styles-with-stylesheets/
|
|
29
29
|
*/
|
|
30
30
|
function {{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init() {
|
|
31
31
|
$dir = __DIR__;
|
|
@@ -26,7 +26,7 @@
|
|
|
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/
|
|
29
|
+
* @see https://developer.wordpress.org/block-editor/how-to-guides/block-tutorial/writing-your-first-block-type/
|
|
30
30
|
*/
|
|
31
31
|
function {{namespaceSnakeCase}}_{{slugSnakeCase}}_block_init() {
|
|
32
32
|
register_block_type( __DIR__ );
|
package/lib/templates.js
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
*/
|
|
4
4
|
const { command } = require( 'execa' );
|
|
5
5
|
const glob = require( 'fast-glob' );
|
|
6
|
+
const { resolve } = require( 'path' );
|
|
7
|
+
const { existsSync } = require( 'fs' );
|
|
6
8
|
const { mkdtemp, readFile } = require( 'fs' ).promises;
|
|
7
9
|
const { fromPairs, isObject } = require( 'lodash' );
|
|
8
10
|
const npmPackageArg = require( 'npm-package-arg' );
|
|
@@ -124,6 +126,9 @@ const getBlockTemplate = async ( templateName ) => {
|
|
|
124
126
|
}
|
|
125
127
|
|
|
126
128
|
try {
|
|
129
|
+
if ( existsSync( resolve( templateName ) ) ) {
|
|
130
|
+
return await configToTemplate( require( resolve( templateName ) ) );
|
|
131
|
+
}
|
|
127
132
|
return await configToTemplate( require( templateName ) );
|
|
128
133
|
} catch ( error ) {
|
|
129
134
|
if ( error instanceof CLIError ) {
|
|
@@ -180,6 +185,7 @@ const getBlockTemplate = async ( templateName ) => {
|
|
|
180
185
|
|
|
181
186
|
const getDefaultValues = ( blockTemplate ) => {
|
|
182
187
|
return {
|
|
188
|
+
$schema: 'https://schemas.wp.org/trunk/block.json',
|
|
183
189
|
apiVersion: 2,
|
|
184
190
|
namespace: 'create-block',
|
|
185
191
|
category: 'widgets',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/create-block",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.7.2-next.33ec3857e2.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,22 +31,22 @@
|
|
|
31
31
|
"wp-create-block": "./index.js"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@wordpress/lazy-import": "^1.3.
|
|
34
|
+
"@wordpress/lazy-import": "^1.3.4-next.33ec3857e2.0",
|
|
35
35
|
"chalk": "^4.0.0",
|
|
36
36
|
"check-node-version": "^4.1.0",
|
|
37
37
|
"commander": "^4.1.0",
|
|
38
38
|
"execa": "^4.0.2",
|
|
39
|
-
"fast-glob": "^
|
|
39
|
+
"fast-glob": "^3.2.7",
|
|
40
40
|
"inquirer": "^7.1.0",
|
|
41
41
|
"lodash": "^4.17.21",
|
|
42
42
|
"make-dir": "^3.0.0",
|
|
43
43
|
"mustache": "^4.0.0",
|
|
44
|
-
"npm-package-arg": "^8.
|
|
44
|
+
"npm-package-arg": "^8.1.5",
|
|
45
45
|
"rimraf": "^3.0.2",
|
|
46
46
|
"write-pkg": "^4.0.0"
|
|
47
47
|
},
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "51c7917ea7fac72953702f24d6daac87d99e7617"
|
|
52
52
|
}
|