@wordpress/create-block 3.0.1-next.a55ed9455a.0 → 3.1.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,11 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.1.0 (2022-04-08)
6
+
7
+ ### New Features
8
+ - Add `npmDevDependencies` template variable to allow definition of `devDependencies` as part of a template ([#39723](https://github.com/WordPress/gutenberg/pull/39723)).
9
+
5
10
  ## 3.0.0 (2022-03-03)
6
11
 
7
12
  ### Breaking Changes
package/README.md CHANGED
@@ -202,6 +202,7 @@ The following configurable variables are used with the template files. Template
202
202
  - `wpEnv` (default: `false`) – enables integration with the `@wordpress/env` package and adds the `env` script to the `package.json`.
203
203
  - `customScripts` (default: {}) – the list of custom scripts to add to `package.json` . It also allows overriding default scripts.
204
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.
205
+ - `npmDevDependencies` (default: `[]`) – the list of remote npm packages to be installed in the project with [`npm install --save-dev`](https://docs.npmjs.com/cli/v8/commands/npm-install) when `wpScripts` is enabled.
205
206
 
206
207
  **Plugin header fields** ([learn more](https://developer.wordpress.org/plugins/plugin-basics/header-requirements/)):
207
208
 
@@ -22,6 +22,7 @@ module.exports = async ( {
22
22
  wpEnv,
23
23
  wpScripts,
24
24
  npmDependencies,
25
+ npmDevDependencies,
25
26
  customScripts,
26
27
  } ) => {
27
28
  const cwd = join( process.cwd(), slug );
@@ -58,30 +59,66 @@ module.exports = async ( {
58
59
  )
59
60
  );
60
61
 
61
- if ( wpScripts && size( npmDependencies ) ) {
62
- info( '' );
63
- info(
64
- 'Installing npm dependencies. It might take a couple of minutes...'
65
- );
66
- for ( const packageArg of npmDependencies ) {
67
- try {
68
- const { type } = npmPackageArg( packageArg );
69
- if (
70
- ! [ 'git', 'tag', 'version', 'range', 'remote' ].includes(
71
- type
72
- )
73
- ) {
74
- throw new Error(
75
- `Provided package type "${ type }" is not supported.`
62
+ /**
63
+ * Helper to determine if we can install this package.
64
+ *
65
+ * @param {string} packageArg The package to install.
66
+ */
67
+ function checkDependency( packageArg ) {
68
+ const { type } = npmPackageArg( packageArg );
69
+ if (
70
+ ! [ 'git', 'tag', 'version', 'range', 'remote' ].includes( type )
71
+ ) {
72
+ throw new Error(
73
+ `Provided package type "${ type }" is not supported.`
74
+ );
75
+ }
76
+ }
77
+
78
+ if ( wpScripts ) {
79
+ if ( size( npmDependencies ) ) {
80
+ info( '' );
81
+ info(
82
+ 'Installing npm dependencies. It might take a couple of minutes...'
83
+ );
84
+ for ( const packageArg of npmDependencies ) {
85
+ try {
86
+ checkDependency( packageArg );
87
+ info( '' );
88
+ info( `Installing "${ packageArg }".` );
89
+ await command( `npm install ${ packageArg }`, {
90
+ cwd,
91
+ } );
92
+ } catch ( { message } ) {
93
+ info( '' );
94
+ info(
95
+ `Skipping "${ packageArg }" npm dependency. Reason:`
96
+ );
97
+ error( message );
98
+ }
99
+ }
100
+ }
101
+
102
+ if ( size( npmDevDependencies ) ) {
103
+ info( '' );
104
+ info(
105
+ 'Installing npm devDependencies. It might take a couple of minutes...'
106
+ );
107
+ for ( const packageArg of npmDevDependencies ) {
108
+ try {
109
+ checkDependency( packageArg );
110
+ info( '' );
111
+ info( `Installing "${ packageArg }".` );
112
+ await command( `npm install ${ packageArg } --save-dev`, {
113
+ cwd,
114
+ } );
115
+ } catch ( { message } ) {
116
+ info( '' );
117
+ info(
118
+ `Skipping "${ packageArg }" npm dev dependency. Reason:`
76
119
  );
120
+ error( message );
77
121
  }
78
- await command( `npm install ${ packageArg }`, {
79
- cwd,
80
- } );
81
- } catch ( { message } ) {
82
- info( '' );
83
- info( `Skipping "${ packageArg }" npm dependency. Reason:` );
84
- error( message );
85
122
  }
86
123
  }
87
124
  }
package/lib/scaffold.js CHANGED
@@ -36,6 +36,7 @@ module.exports = async (
36
36
  wpScripts,
37
37
  wpEnv,
38
38
  npmDependencies,
39
+ npmDevDependencies,
39
40
  customScripts,
40
41
  folderName,
41
42
  editorScript,
@@ -74,6 +75,7 @@ module.exports = async (
74
75
  wpScripts,
75
76
  wpEnv,
76
77
  npmDependencies,
78
+ npmDevDependencies,
77
79
  customScripts,
78
80
  folderName,
79
81
  editorScript,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/create-block",
3
- "version": "3.0.1-next.a55ed9455a.0",
3
+ "version": "3.1.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.2-next.a55ed9455a.0",
34
+ "@wordpress/lazy-import": "^1.4.2",
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": "c5108185851b824d531bce55991a3589947e8551"
51
+ "gitHead": "11eb1241e63c9240018323551c6753f8a5fa96f9"
52
52
  }