@wordpress/create-block 3.5.0 → 3.7.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,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.6.0 (2022-07-13)
6
+
7
+ ### Enhancement
8
+
9
+ - Added prompt to continue when minimum system requirements not met ([#42151](https://github.com/WordPress/gutenberg/pull/42151)).
10
+
5
11
  ## 3.3.0 (2022-06-01)
6
12
 
7
13
  ### Enhancement
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
+ const inquirer = require( 'inquirer' );
4
5
  const checkSync = require( 'check-node-version' );
6
+ const tools = require( 'check-node-version/tools' );
5
7
  const { forEach } = require( 'lodash' );
6
8
  const { promisify } = require( 'util' );
7
9
 
@@ -14,20 +16,45 @@ const check = promisify( checkSync );
14
16
 
15
17
  async function checkSystemRequirements( engines ) {
16
18
  const result = await check( engines );
19
+
17
20
  if ( ! result.isSatisfied ) {
18
21
  log.error( 'Minimum system requirements not met!' );
19
22
  log.info( '' );
23
+
20
24
  forEach( result.versions, ( { isSatisfied, wanted }, name ) => {
21
25
  if ( ! isSatisfied ) {
22
26
  log.error(
23
27
  `Error: Wanted ${ name } version ${ wanted.raw } (${ wanted.range })`
24
28
  );
25
- log.info(
26
- check.PROGRAMS[ name ].getInstallInstructions( wanted.raw )
27
- );
28
29
  }
29
30
  } );
30
- process.exit( 1 );
31
+
32
+ log.info( '' );
33
+ log.error( 'The program may not complete correctly if you continue.' );
34
+ log.info( '' );
35
+
36
+ const { yesContinue } = await inquirer.prompt( [
37
+ {
38
+ type: 'confirm',
39
+ name: 'yesContinue',
40
+ message: 'Are you sure you want to continue anyway?',
41
+ default: false,
42
+ },
43
+ ] );
44
+
45
+ if ( ! yesContinue ) {
46
+ log.error( 'Cancelled.' );
47
+ log.info( '' );
48
+
49
+ forEach( result.versions, ( { isSatisfied, wanted }, name ) => {
50
+ if ( ! isSatisfied ) {
51
+ log.info(
52
+ tools[ name ].getInstallInstructions( wanted.raw )
53
+ );
54
+ }
55
+ } );
56
+ process.exit( 1 );
57
+ }
31
58
  }
32
59
  }
33
60
 
@@ -76,7 +76,7 @@ module.exports = async ( {
76
76
  }
77
77
 
78
78
  if ( wpScripts ) {
79
- if ( npmDependencies.length ) {
79
+ if ( npmDependencies && npmDependencies.length ) {
80
80
  info( '' );
81
81
  info(
82
82
  'Installing npm dependencies. It might take a couple of minutes...'
@@ -99,7 +99,7 @@ module.exports = async ( {
99
99
  }
100
100
  }
101
101
 
102
- if ( npmDevDependencies.length ) {
102
+ if ( npmDevDependencies && npmDevDependencies.length ) {
103
103
  info( '' );
104
104
  info(
105
105
  'Installing npm devDependencies. It might take a couple of minutes...'
package/lib/scaffold.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * External dependencies
3
3
  */
4
- const { snakeCase, camelCase, upperFirst } = require( 'lodash' );
4
+ const { camelCase, snakeCase } = require( 'change-case' );
5
5
 
6
6
  /**
7
7
  * Internal dependencies
@@ -13,6 +13,10 @@ const initWPEnv = require( './init-wp-env' );
13
13
  const { code, info, success } = require( './log' );
14
14
  const { writeOutputAsset, writeOutputTemplate } = require( './output' );
15
15
 
16
+ function upperFirst( str ) {
17
+ return str.charAt( 0 ).toUpperCase() + str.substr( 1 );
18
+ }
19
+
16
20
  module.exports = async (
17
21
  { blockOutputTemplates, pluginOutputTemplates, outputAssets },
18
22
  {
package/lib/templates.js CHANGED
@@ -6,7 +6,6 @@ const glob = require( 'fast-glob' );
6
6
  const { resolve } = require( 'path' );
7
7
  const { existsSync } = require( 'fs' );
8
8
  const { mkdtemp, readFile } = require( 'fs' ).promises;
9
- const { fromPairs, isObject } = require( 'lodash' );
10
9
  const npmPackageArg = require( 'npm-package-arg' );
11
10
  const { tmpdir } = require( 'os' );
12
11
  const { join } = require( 'path' );
@@ -53,7 +52,7 @@ const getOutputTemplates = async ( outputTemplatesPath ) => {
53
52
  cwd: outputTemplatesPath,
54
53
  dot: true,
55
54
  } );
56
- return fromPairs(
55
+ return Object.fromEntries(
57
56
  await Promise.all(
58
57
  outputTemplatesFiles.map( async ( outputTemplateFile ) => {
59
58
  const outputFile = outputTemplateFile.replace(
@@ -75,7 +74,7 @@ const getOutputAssets = async ( outputAssetsPath ) => {
75
74
  cwd: outputAssetsPath,
76
75
  dot: true,
77
76
  } );
78
- return fromPairs(
77
+ return Object.fromEntries(
79
78
  await Promise.all(
80
79
  outputAssetFiles.map( async ( outputAssetFile ) => {
81
80
  const outputAsset = await readFile(
@@ -103,7 +102,7 @@ const configToTemplate = async ( {
103
102
  assetsPath,
104
103
  ...deprecated
105
104
  } ) => {
106
- if ( ! isObject( defaultValues ) ) {
105
+ if ( defaultValues === null || typeof defaultValues !== 'object' ) {
107
106
  throw new CLIError( 'Template found but invalid definition provided.' );
108
107
  }
109
108
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/create-block",
3
- "version": "3.5.0",
3
+ "version": "3.7.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",
@@ -33,6 +33,7 @@
33
33
  "dependencies": {
34
34
  "@wordpress/lazy-import": "^1.4.2",
35
35
  "chalk": "^4.0.0",
36
+ "change-case": "^4.1.2",
36
37
  "check-node-version": "^4.1.0",
37
38
  "commander": "^9.2.0",
38
39
  "execa": "^4.0.2",
@@ -48,5 +49,5 @@
48
49
  "publishConfig": {
49
50
  "access": "public"
50
51
  },
51
- "gitHead": "a80eeb62ec7cb1418b9915c277e084a29d6665e3"
52
+ "gitHead": "0315dbc240cb2aa146d7c1bafd251f004b88300e"
52
53
  }