@wordpress/create-block 4.70.0 → 4.71.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/lib/scaffold.js +34 -5
- package/lib/templates.js +2 -0
- package/package.json +3 -3
package/lib/scaffold.js
CHANGED
|
@@ -13,6 +13,7 @@ const initWPScripts = require( './init-wp-scripts' );
|
|
|
13
13
|
const initWPEnv = require( './init-wp-env' );
|
|
14
14
|
const { code, info, success, error } = require( './log' );
|
|
15
15
|
const { writeOutputAsset, writeOutputTemplate } = require( './output' );
|
|
16
|
+
const { getOutputTemplates, getOutputAssets } = require( './templates' );
|
|
16
17
|
|
|
17
18
|
module.exports = async (
|
|
18
19
|
{ blockOutputTemplates, pluginOutputTemplates, outputAssets },
|
|
@@ -58,6 +59,9 @@ module.exports = async (
|
|
|
58
59
|
customBlockJSON,
|
|
59
60
|
example,
|
|
60
61
|
transformer,
|
|
62
|
+
pluginTemplatesPath: variantPluginTemplatesPath,
|
|
63
|
+
blockTemplatesPath: variantBlockTemplatesPath,
|
|
64
|
+
assetsPath: variantAssetsPath,
|
|
61
65
|
}
|
|
62
66
|
) => {
|
|
63
67
|
slug = slug.toLowerCase();
|
|
@@ -114,12 +118,37 @@ module.exports = async (
|
|
|
114
118
|
...variantVars,
|
|
115
119
|
};
|
|
116
120
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
121
|
+
// Check for the pluginTemplates path in the variant
|
|
122
|
+
if ( variantPluginTemplatesPath === null ) {
|
|
123
|
+
pluginOutputTemplates = {};
|
|
124
|
+
} else if ( variantPluginTemplatesPath ) {
|
|
125
|
+
pluginOutputTemplates = await getOutputTemplates(
|
|
126
|
+
variantPluginTemplatesPath
|
|
127
|
+
);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
// Check for the blockTemplatesPath path in the variant
|
|
131
|
+
if ( variantBlockTemplatesPath === null ) {
|
|
132
|
+
blockOutputTemplates = {};
|
|
133
|
+
} else if ( variantBlockTemplatesPath ) {
|
|
134
|
+
blockOutputTemplates = await getOutputTemplates(
|
|
135
|
+
variantBlockTemplatesPath
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
// Check for the assetsPath
|
|
140
|
+
if ( variantAssetsPath === null ) {
|
|
141
|
+
outputAssets = {};
|
|
142
|
+
} else if ( variantAssetsPath ) {
|
|
143
|
+
outputAssets = await getOutputAssets( variantAssetsPath );
|
|
144
|
+
}
|
|
145
|
+
|
|
122
146
|
if ( ! plugin && Object.keys( blockOutputTemplates ) < 1 ) {
|
|
147
|
+
/**
|
|
148
|
+
* --no-plugin relies on the used template supporting the [blockTemplatesPath property](https://developer.wordpress.org/block-editor/reference-guides/packages/packages-create-block/#blocktemplatespath).
|
|
149
|
+
* If the blockOutputTemplates object has no properties, we can assume that there was a custom --template passed that
|
|
150
|
+
* doesn't support it.
|
|
151
|
+
*/
|
|
123
152
|
error(
|
|
124
153
|
'No block files found in the template. Please ensure that the template supports the blockTemplatesPath property.'
|
|
125
154
|
);
|
package/lib/templates.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/create-block",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.71.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",
|
|
@@ -32,7 +32,7 @@
|
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@inquirer/prompts": "^7.2.0",
|
|
35
|
-
"@wordpress/lazy-import": "^2.
|
|
35
|
+
"@wordpress/lazy-import": "^2.28.0",
|
|
36
36
|
"chalk": "^4.0.0",
|
|
37
37
|
"change-case": "^4.1.2",
|
|
38
38
|
"check-node-version": "^4.1.0",
|
|
@@ -48,5 +48,5 @@
|
|
|
48
48
|
"publishConfig": {
|
|
49
49
|
"access": "public"
|
|
50
50
|
},
|
|
51
|
-
"gitHead": "
|
|
51
|
+
"gitHead": "28cc2098f5ee28f89096b638533796538f495f72"
|
|
52
52
|
}
|