This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | /** |
||
2 | * Build |
||
3 | * |
||
4 | * The create-guten-block CLI builds here. |
||
5 | */ |
||
6 | |||
7 | 'use strict'; |
||
0 ignored issues
–
show
Coding Style
introduced
by
![]() |
|||
8 | |||
9 | // Do this as the first thing so that any code reading it knows the right env. |
||
10 | process.env.BABEL_ENV = 'production'; |
||
0 ignored issues
–
show
|
|||
11 | process.env.NODE_ENV = 'production'; |
||
0 ignored issues
–
show
|
|||
12 | |||
13 | // Makes the script crash on unhandled rejections instead of silently |
||
14 | // ignoring them. In the future, promise rejections that are not handled will |
||
15 | // terminate the Node.js process with a non-zero exit code. |
||
16 | process.on( 'unhandledRejection', err => { |
||
0 ignored issues
–
show
'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: ![]() |
|||
17 | throw err; |
||
18 | } ); |
||
19 | |||
20 | // Modules. |
||
21 | const fs = require( 'fs' ); |
||
0 ignored issues
–
show
|
|||
22 | const ora = require( 'ora' ); |
||
0 ignored issues
–
show
|
|||
23 | const path = require( 'path' ); |
||
0 ignored issues
–
show
|
|||
24 | const chalk = require( 'chalk' ); |
||
0 ignored issues
–
show
|
|||
25 | const webpack = require( 'webpack' ); |
||
0 ignored issues
–
show
|
|||
26 | const fileSize = require( 'filesize' ); |
||
0 ignored issues
–
show
|
|||
27 | const gzipSize = require( 'gzip-size' ); |
||
0 ignored issues
–
show
|
|||
28 | const resolvePkg = require( 'resolve-pkg' ); |
||
0 ignored issues
–
show
|
|||
29 | const config = require( '../config/webpack.config.prod' ); |
||
0 ignored issues
–
show
There were too many errors found in this file; checking aborted after 20%.
If JSHint finds too many errors in a file, it aborts checking altogether because it suspects a configuration issue. Further Reading: ![]() |
|||
30 | const cgbDevUtilsPath = resolvePkg( 'cgb-dev-utils', { cwd: __dirname } ); |
||
0 ignored issues
–
show
|
|||
31 | const clearConsole = require( cgbDevUtilsPath + '/clearConsole' ); |
||
0 ignored issues
–
show
|
|||
32 | const formatWebpackMessages = require( cgbDevUtilsPath + |
||
0 ignored issues
–
show
|
|||
33 | '/formatWebpackMessages' ); |
||
34 | |||
35 | // Build file paths. |
||
36 | const theCWD = process.cwd(); |
||
0 ignored issues
–
show
|
|||
37 | const fileBuildJS = path.resolve( theCWD, './gutenberg/dist/blocks.build.js' ); |
||
0 ignored issues
–
show
|
|||
38 | const fileEditorCSS = path.resolve( theCWD, './gutenberg/dist/blocks.editor.build.css' ); |
||
0 ignored issues
–
show
|
|||
39 | const fileStyleCSS = path.resolve( theCWD, './gutenberg/dist/blocks.style.build.css' ); |
||
0 ignored issues
–
show
|
|||
40 | |||
41 | /** |
||
42 | * Get File Size |
||
43 | * |
||
44 | * Get filesizes of all the files. |
||
45 | * |
||
46 | * @param {string} filePath path. |
||
47 | * @returns {string} then size result. |
||
48 | */ |
||
49 | const getFileSize = filePath => { |
||
0 ignored issues
–
show
'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: ![]() |
|||
50 | return fileSize( gzipSize.sync( fs.readFileSync( filePath ) ) ); |
||
51 | }; |
||
52 | |||
53 | clearConsole(); |
||
54 | |||
55 | // Init the spinner. |
||
56 | const spinner = new ora( { text: '' } ); |
||
0 ignored issues
–
show
|
|||
57 | |||
58 | /** |
||
59 | * Build function |
||
60 | * |
||
61 | * Create the production build and print the deployment instructions. |
||
62 | * |
||
63 | * @param {json} webpackConfig config |
||
64 | */ |
||
65 | async function build( webpackConfig ) { |
||
0 ignored issues
–
show
Did you forget to assign or call a function?
This error message can for example pop up if you forget to assign the result of a function call to a variable or pass it to another function: function someFunction(x) {
(x > 0) ? callFoo() : callBar();
}
// JSHint expects you to assign the result to a variable:
function someFunction(x) {
var rs = (x > 0) ? callFoo() : callBar();
}
// If you do not use the result, you could also use if statements in the
// case above.
function someFunction(x) {
if (x > 0) {
callFoo();
} else {
callBar();
}
}
![]() |
|||
66 | // Compiler Instance. |
||
67 | const compiler = await webpack( webpackConfig ); |
||
0 ignored issues
–
show
|
|||
68 | |||
69 | // Run the compiler. |
||
70 | compiler.run( ( err, stats ) => { |
||
0 ignored issues
–
show
'arrow function syntax (=>)' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: ![]() |
|||
71 | clearConsole(); |
||
72 | |||
73 | if ( err ) { |
||
74 | return console.log( err ); |
||
75 | } |
||
76 | |||
77 | // Get the messages formatted. |
||
78 | const messages = formatWebpackMessages( stats.toJson( {}, true ) ); |
||
0 ignored issues
–
show
|
|||
79 | |||
80 | // If there are errors just show the errors. |
||
81 | if ( messages.errors.length ) { |
||
82 | // Only keep the first error. Others are often indicative |
||
83 | // of the same problem, but confuse the reader with noise. |
||
84 | if ( messages.errors.length > 1 ) { |
||
85 | messages.errors.length = 1; |
||
86 | } |
||
87 | // Formatted errors. |
||
88 | clearConsole(); |
||
89 | console.log( '\n❌ ', chalk.black.bgRed( ' Failed to compile build. \n' ) ); |
||
90 | console.log( '\n👉 ', messages.errors.join( '\n\n' ) ); |
||
91 | |||
92 | // Don't go beyond this point at this time. |
||
93 | return; |
||
94 | } |
||
95 | |||
96 | // CI. |
||
97 | if ( |
||
98 | process.env.CI && |
||
0 ignored issues
–
show
|
|||
99 | ( typeof process.env.CI !== 'string' || |
||
0 ignored issues
–
show
|
|||
100 | process.env.CI.toLowerCase() !== 'false' ) && |
||
0 ignored issues
–
show
|
|||
101 | messages.warnings.length |
||
102 | ) { |
||
103 | console.log( |
||
104 | chalk.yellow( |
||
105 | '\nTreating warnings as errors because process.env.CI = true.\n' + |
||
106 | 'Most CI servers set it automatically.\n' |
||
107 | ) |
||
108 | ); |
||
109 | console.log( messages.warnings.join( '\n\n' ) ); |
||
110 | } |
||
111 | |||
112 | // Start the build. |
||
113 | console.log( `\n ${ chalk.dim( 'Let\'s build and compile the files...' ) }` ); |
||
0 ignored issues
–
show
'template literal syntax' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: ![]() |
|||
114 | console.log( '\n✅ ', chalk.black.bgGreen( ' Built successfully! \n' ) ); |
||
115 | |||
116 | console.log( |
||
117 | '\n\n', |
||
118 | 'File sizes after gzip:', |
||
119 | '\n\n', |
||
120 | getFileSize( fileBuildJS ), |
||
121 | `${ chalk.dim( '— ./gutenberg/dist/' ) }`, |
||
0 ignored issues
–
show
'template literal syntax' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: ![]() |
|||
122 | `${ chalk.green( 'blocks.build.js' ) }`, |
||
0 ignored issues
–
show
'template literal syntax' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: ![]() |
|||
123 | '\n', |
||
124 | getFileSize( fileEditorCSS ), |
||
125 | `${ chalk.dim( '— ./gutenberg/dist/' ) }`, |
||
0 ignored issues
–
show
'template literal syntax' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: ![]() |
|||
126 | `${ chalk.green( 'blocks.editor.build.css' ) }`, |
||
0 ignored issues
–
show
'template literal syntax' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: ![]() |
|||
127 | |||
128 | '\n', |
||
129 | getFileSize( fileStyleCSS ), |
||
130 | `${ chalk.dim( '— ./gutenberg/dist/' ) }`, |
||
0 ignored issues
–
show
'template literal syntax' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: ![]() |
|||
131 | `${ chalk.green( 'blocks.style.build.css' ) }`, |
||
0 ignored issues
–
show
'template literal syntax' is only available in ES6 (use 'esversion: 6').
Generally using ECMAScript 6 specific syntax is fine if you are sure that it is already supported by all engines which are supposed to run this code. Further Reading: ![]() |
|||
132 | |||
133 | '\n\n' |
||
134 | ); |
||
135 | |||
136 | return true; |
||
137 | } ); |
||
138 | } |
||
139 | |||
140 | build( config ); |
||
141 |