@wordpress/create-block 4.72.1-next.f34ab90e9.0 → 4.73.1-next.e256d081a.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.
@@ -29,6 +29,55 @@ module.exports = async ( {
29
29
  info( '' );
30
30
  info( 'Creating a "package.json" file.' );
31
31
 
32
+ /**
33
+ * Helper to determine if we can install this package.
34
+ *
35
+ * @param {string} packageArg The package to install.
36
+ */
37
+ function checkDependency( packageArg ) {
38
+ const { type } = npmPackageArg( packageArg );
39
+ if (
40
+ ! [ 'git', 'tag', 'version', 'range', 'remote' ].includes( type )
41
+ ) {
42
+ throw new Error(
43
+ `Provided package type "${ type }" is not supported.`
44
+ );
45
+ }
46
+ }
47
+
48
+ const dependencies = {};
49
+ const devDependencies = {};
50
+
51
+ if ( npmDependencies && npmDependencies.length ) {
52
+ for ( const packageArg of npmDependencies ) {
53
+ try {
54
+ checkDependency( packageArg );
55
+ const parsed = npmPackageArg( packageArg );
56
+ dependencies[ parsed.name ] = parsed.saveSpec || 'latest';
57
+ } catch ( { message } ) {
58
+ info( '' );
59
+ info( `Skipping "${ packageArg }" npm dependency. Reason:` );
60
+ error( message );
61
+ }
62
+ }
63
+ }
64
+
65
+ if ( npmDevDependencies && npmDevDependencies.length ) {
66
+ for ( const packageArg of npmDevDependencies ) {
67
+ try {
68
+ checkDependency( packageArg );
69
+ const parsed = npmPackageArg( packageArg );
70
+ devDependencies[ parsed.name ] = parsed.saveSpec || 'latest';
71
+ } catch ( { message } ) {
72
+ info( '' );
73
+ info(
74
+ `Skipping "${ packageArg }" npm dev dependency. Reason:`
75
+ );
76
+ error( message );
77
+ }
78
+ }
79
+ }
80
+
32
81
  await writePkg(
33
82
  rootDirectory,
34
83
  Object.fromEntries(
@@ -59,71 +108,42 @@ module.exports = async ( {
59
108
  ...( wpEnv && { env: 'wp-env' } ),
60
109
  ...customScripts,
61
110
  },
111
+ dependencies:
112
+ Object.keys( dependencies ).length > 0
113
+ ? dependencies
114
+ : undefined,
115
+ devDependencies:
116
+ Object.keys( devDependencies ).length > 0
117
+ ? devDependencies
118
+ : undefined,
62
119
  ...customPackageJSON,
63
120
  } ).filter( ( [ , value ] ) => !! value )
64
121
  )
65
122
  );
66
123
 
67
- /**
68
- * Helper to determine if we can install this package.
69
- *
70
- * @param {string} packageArg The package to install.
71
- */
72
- function checkDependency( packageArg ) {
73
- const { type } = npmPackageArg( packageArg );
124
+ if ( wpScripts ) {
74
125
  if (
75
- ! [ 'git', 'tag', 'version', 'range', 'remote' ].includes( type )
126
+ Object.keys( dependencies ).length > 0 ||
127
+ Object.keys( devDependencies ).length > 0
76
128
  ) {
77
- throw new Error(
78
- `Provided package type "${ type }" is not supported.`
79
- );
80
- }
81
- }
82
-
83
- if ( wpScripts ) {
84
- if ( npmDependencies && npmDependencies.length ) {
85
129
  info( '' );
86
130
  info(
87
131
  'Installing npm dependencies. It might take a couple of minutes...'
88
132
  );
89
- for ( const packageArg of npmDependencies ) {
90
- try {
91
- checkDependency( packageArg );
92
- info( '' );
93
- info( `Installing "${ packageArg }".` );
94
- await command( `npm install ${ packageArg }`, {
95
- cwd: rootDirectory,
96
- } );
97
- } catch ( { message } ) {
98
- info( '' );
99
- info(
100
- `Skipping "${ packageArg }" npm dependency. Reason:`
101
- );
102
- error( message );
103
- }
104
- }
105
- }
106
133
 
107
- if ( npmDevDependencies && npmDevDependencies.length ) {
108
- info( '' );
109
- info(
110
- 'Installing npm devDependencies. It might take a couple of minutes...'
111
- );
112
- for ( const packageArg of npmDevDependencies ) {
113
- try {
114
- checkDependency( packageArg );
115
- info( '' );
116
- info( `Installing "${ packageArg }".` );
117
- await command( `npm install ${ packageArg } --save-dev`, {
118
- cwd: rootDirectory,
119
- } );
120
- } catch ( { message } ) {
121
- info( '' );
122
- info(
123
- `Skipping "${ packageArg }" npm dev dependency. Reason:`
124
- );
125
- error( message );
126
- }
134
+ try {
135
+ await command( 'npm install', {
136
+ cwd: rootDirectory,
137
+ } );
138
+
139
+ info( '' );
140
+ info(
141
+ 'Successfully installed dependencies and ran lifecycle scripts.'
142
+ );
143
+ } catch ( { message } ) {
144
+ info( '' );
145
+ info( 'Warning: Failed to install dependencies:' );
146
+ error( message );
127
147
  }
128
148
  }
129
149
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/create-block",
3
- "version": "4.72.1-next.f34ab90e9.0",
3
+ "version": "4.73.1-next.e256d081a.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.29.1-next.f34ab90e9.0",
35
+ "@wordpress/lazy-import": "^2.29.1-next.e256d081a.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": "91f58004986ec6faf118825f925ac7873d171986"
51
+ "gitHead": "7d529ba9a461795d5f1572d3856de33f744287c2"
52
52
  }