From 814aa7149f0175fdc12d6796ba8b2b5afaeb947a Mon Sep 17 00:00:00 2001 From: John Blackbourn Date: Sun, 26 May 2019 19:34:24 +0000 Subject: [PATCH] Build/Test Tools: Remove the dependency on a globally installed Grunt. The existing `"grunt": "grunt"` script in `package.json` allows for the use of `npm run grunt ...` which uses the local `grunt` binary in the project's `node_modules`. Fixes #47380 git-svn-id: https://develop.svn.wordpress.org/trunk@45445 602fd350-edb4-49c9-b593-d223f7449a82 --- .travis.yml | 4 +--- appveyor.yml | 3 +-- package.json | 8 ++++++-- src/index.php | 13 ++++++------- src/wp-includes/embed.php | 6 +++--- src/wp-includes/formatting.php | 4 ++-- tests/phpunit/includes/bootstrap.php | 2 +- tests/phpunit/tests/oembed/template.php | 2 +- 8 files changed, 21 insertions(+), 21 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0e186dc8c7..c866b87e6e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -89,7 +89,6 @@ before_script: - npm --version - node --version - nvm install 10.13.0 -- npm install -g grunt-cli - npm install - npm prune - mysql --version @@ -101,11 +100,10 @@ before_script: - which phpunit - phpunit --version - curl --version -- grunt --version - git --version - svn --version - locale -a -script: grunt $WP_TRAVISCI +script: npm run grunt $WP_TRAVISCI after_script: - | if [[ "$WP_TEST_REPORTER" == "true" ]]; then diff --git a/appveyor.yml b/appveyor.yml index cb0a8ae453..f5d7edf00a 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -11,7 +11,6 @@ branches: install: - ps: Install-Product node $env:nodejs_version - npm install npm -g - - npm install grunt-cli -g - npm install before_build: @@ -19,7 +18,7 @@ before_build: - npm --version build_script: - - cmd: "grunt build" + - cmd: "npm run build" test: off diff --git a/package.json b/package.json index 5dc8dc6756..d28d60a1ca 100644 --- a/package.json +++ b/package.json @@ -19,7 +19,7 @@ "check-node-version": "3.2.0", "copy-webpack-plugin": "^4.6.0", "cssnano": "4.1.8", - "grunt": "~1.0.3", + "grunt": "1.0.4", "grunt-banner": "^0.6.0", "grunt-contrib-clean": "~2.0.0", "grunt-contrib-concat": "~1.0.0", @@ -46,7 +46,7 @@ "matchdep": "~2.0.0", "node-sass": "~4.12.0", "source-map-loader": "^0.2.4", - "uglify-js": "^3.4.9", + "uglify-js": "3.5.15", "uglifyjs-webpack-plugin": "2.1.1", "webpack": "4.29.2", "webpack-dev-server": "3.1.14", @@ -113,6 +113,10 @@ "whatwg-fetch": "3.0.0" }, "scripts": { + "build": "grunt build", + "dev": "grunt build --dev", + "test": "grunt test", + "watch": "grunt watch", "grunt": "grunt" } } diff --git a/src/index.php b/src/index.php index c76c36d72d..a992feba51 100644 --- a/src/index.php +++ b/src/index.php @@ -34,24 +34,23 @@ $die = __( 'You are running WordPress without JavaScript and CSS files. These ne $die .= '

' . sprintf( /* translators: %s: npm install */ - __( 'Before running any grunt tasks you need to make sure the dependencies are installed. You can install these by running %s.' ), + __( 'Before running any build tasks you need to make sure the dependencies are installed. You can install these by running %s.' ), 'npm install' ) . '

'; $die .= ''; $die .= '

' . sprintf( - /* translators: 1: NPM URL, 2: Grunt URL, 3: Handbook URL */ - __( 'This requires NPM and Grunt. Read more about setting up your local development environment.' ), + /* translators: 1: NPM URL, 2: Handbook URL */ + __( 'This requires NPM. Read more about setting up your local development environment.' ), 'https://www.npmjs.com/get-npm', - 'https://gruntjs.com/getting-started', __( 'https://make.wordpress.org/core/handbook/tutorials/installing-wordpress-locally/' ) ) . '

'; diff --git a/src/wp-includes/embed.php b/src/wp-includes/embed.php index 6bc220e9ad..76d937cd6c 100644 --- a/src/wp-includes/embed.php +++ b/src/wp-includes/embed.php @@ -446,7 +446,7 @@ function get_post_embed_html( $width, $height, $post = null ) { } else { /* * If you're looking at a src version of this file, you'll see an "include" - * statement below. This is used by the `grunt build` process to directly + * statement below. This is used by the `npm run build` process to directly * include a minified version of wp-embed.js, instead of using the * file_get_contents() method from above. * @@ -1008,7 +1008,7 @@ function print_embed_styles() { } else { /* * If you're looking at a src version of this file, you'll see an "include" - * statement below. This is used by the `grunt build` process to directly + * statement below. This is used by the `npm run build` process to directly * include a minified version of wp-oembed-embed.css, instead of using the * readfile() method from above. * @@ -1039,7 +1039,7 @@ function print_embed_scripts() { } else { /* * If you're looking at a src version of this file, you'll see an "include" - * statement below. This is used by the `grunt build` process to directly + * statement below. This is used by the `npm run build` process to directly * include a minified version of wp-embed-template.js, instead of using the * readfile() method from above. * diff --git a/src/wp-includes/formatting.php b/src/wp-includes/formatting.php index bd879e4835..51a1388dfd 100644 --- a/src/wp-includes/formatting.php +++ b/src/wp-includes/formatting.php @@ -5520,7 +5520,7 @@ function _print_emoji_detection_script() { /* * If you're looking at a src version of this file, you'll see an "include" - * statement below. This is used by the `grunt build` process to directly + * statement below. This is used by the `npm run build` process to directly * include a minified version of wp-emoji-loader.js, instead of using the * readfile() method from above. * @@ -5736,7 +5736,7 @@ function wp_staticize_emoji_for_email( $mail ) { * Returns arrays of emoji data. * * These arrays are automatically built from the regex in twemoji.js - if they need to be updated, - * you should update the regex there, then run the `grunt precommit:emoji` job. + * you should update the regex there, then run the `npm run grunt precommit:emoji` job. * * @since 4.9.0 * @access private diff --git a/tests/phpunit/includes/bootstrap.php b/tests/phpunit/includes/bootstrap.php index 23faca64e5..f46f56d7cb 100644 --- a/tests/phpunit/includes/bootstrap.php +++ b/tests/phpunit/includes/bootstrap.php @@ -47,7 +47,7 @@ if ( version_compare( tests_get_phpunit_version(), '8.0', '>=' ) ) { } if ( defined( 'WP_RUN_CORE_TESTS' ) && WP_RUN_CORE_TESTS && ! is_dir( ABSPATH ) ) { - echo "ERROR: The /build/ directory is missing! Please run `grunt build` prior to running PHPUnit.\n"; + echo "ERROR: The /build/ directory is missing! Please run `npm run build` prior to running PHPUnit.\n"; exit( 1 ); } diff --git a/tests/phpunit/tests/oembed/template.php b/tests/phpunit/tests/oembed/template.php index 95c532edb0..3d9b2b90c1 100644 --- a/tests/phpunit/tests/oembed/template.php +++ b/tests/phpunit/tests/oembed/template.php @@ -309,7 +309,7 @@ class Tests_Embed_Template extends WP_UnitTestCase { * So this test checks for ampersands in build/wp-includes/js/wp-embed.min.js. * In many cases, this file will not exist; in those cases, we simply skip the test. * - * So when would it be run? We have Travis CI run `grunt test` which then runs, in order, + * So when would it be run? We have Travis CI run `npm run test` which then runs, in order, * `qunit:compiled` (which runs the build) and then `phpunit`. Thus, this test will at least be * run during continuous integration. *