diff --git a/.github/workflows/reusable-check-built-files.yml b/.github/workflows/reusable-check-built-files.yml index 033b2a46ac3e9..5a673bf496ace 100644 --- a/.github/workflows/reusable-check-built-files.yml +++ b/.github/workflows/reusable-check-built-files.yml @@ -24,9 +24,10 @@ jobs: # - Builds Emoji files. # - Builds bundled Root Certificate files. # - Builds WordPress. - # - Checks for changes to versioned files. - # - Displays the result of git diff for debugging purposes. - # - Saves the diff to a patch file. + # - Checks for uncommitted changes. + # - Stages all uncommitted changes and adds any unversioned files. + # - Displays a diff of all staged changes. + # - Saves staged changes to a .diff file. # - Uploads the patch file as an artifact. update-built-files: name: Check and update built files @@ -78,22 +79,26 @@ jobs: - name: Build WordPress run: npm run build:dev - - name: Check for changes to versioned files + - name: Check for uncommitted changes id: built-file-check run: | - if git diff --quiet; then + if [ -z "$(git status --porcelain)" ]; then echo "uncommitted_changes=false" >> "$GITHUB_OUTPUT" else echo "uncommitted_changes=true" >> "$GITHUB_OUTPUT" fi - - name: Display changes to versioned files + - name: Stage all changes for diff generation if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }} - run: git diff + run: git add -A + + - name: Display all uncommitted changes + if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }} + run: git diff --cached - name: Save diff to a file if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }} - run: git diff > ./changes.diff + run: git diff --cached --binary > ./changes.diff # Uploads the diff file as an artifact. - name: Upload diff file as artifact diff --git a/.github/workflows/reusable-coding-standards-javascript.yml b/.github/workflows/reusable-coding-standards-javascript.yml index eac5bbdc352f2..b15a5bacf6d46 100644 --- a/.github/workflows/reusable-coding-standards-javascript.yml +++ b/.github/workflows/reusable-coding-standards-javascript.yml @@ -24,7 +24,7 @@ jobs: # - Logs debug information about the GitHub Action runner. # - Installs npm dependencies. # - Run the WordPress JSHint checks. - # - Ensures version-controlled files are not modified or deleted. + # - Checks for any uncommitted changes. jshint: name: JavaScript checks runs-on: ubuntu-24.04 @@ -57,5 +57,10 @@ jobs: - name: Run JSHint run: npm run grunt jshint - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code + - name: Check for uncommitted changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Uncommitted changes detected:" + git status --porcelain + exit 1 + fi diff --git a/.github/workflows/reusable-coding-standards-php.yml b/.github/workflows/reusable-coding-standards-php.yml index 709c598872b23..bff2282fb1296 100644 --- a/.github/workflows/reusable-coding-standards-php.yml +++ b/.github/workflows/reusable-coding-standards-php.yml @@ -36,7 +36,7 @@ jobs: # - Generate a report for displaying issues as pull request annotations. # - Runs PHPCS on the `tests` directory without (warnings included). # - Generate a report for displaying `test` directory issues as pull request annotations. - # - Ensures version-controlled files are not modified or deleted. + # - Checks for any uncommitted changes. phpcs: name: PHP checks runs-on: ubuntu-24.04 @@ -104,5 +104,10 @@ jobs: if: ${{ inputs.old-branch }} run: phpcbf - - name: Ensure version-controlled files are not modified during the tests - run: git diff --exit-code + - name: Check for uncommitted changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Uncommitted changes detected:" + git status --porcelain + exit 1 + fi diff --git a/.github/workflows/reusable-end-to-end-tests.yml b/.github/workflows/reusable-end-to-end-tests.yml index 87f90f1b53039..c39e03a6c0ab0 100644 --- a/.github/workflows/reusable-end-to-end-tests.yml +++ b/.github/workflows/reusable-end-to-end-tests.yml @@ -61,7 +61,7 @@ jobs: # - Install additional languages. # - Run the E2E tests. # - Uploads screenshots and HTML snapshots as an artifact. - # - Ensures version-controlled files are not modified or deleted. + # - Checks for any uncommitted changes. e2e-tests: name: SCRIPT_DEBUG ${{ inputs.LOCAL_SCRIPT_DEBUG && 'enabled' || 'disabled' }} runs-on: ubuntu-24.04 @@ -153,5 +153,10 @@ jobs: if-no-files-found: ignore include-hidden-files: true - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code + - name: Check for uncommitted changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Uncommitted changes detected:" + git status --porcelain + exit 1 + fi diff --git a/.github/workflows/reusable-javascript-tests.yml b/.github/workflows/reusable-javascript-tests.yml index 3988ec9d6b055..d260dd71c4c11 100644 --- a/.github/workflows/reusable-javascript-tests.yml +++ b/.github/workflows/reusable-javascript-tests.yml @@ -25,7 +25,7 @@ jobs: # - Logs debug information about the GitHub Action runner. # - Installs npm dependencies. # - Run the WordPress QUnit tests. - # - Ensures version-controlled files are not modified or deleted. + # - Checks for any uncommitted changes. test-js: name: Run QUnit tests runs-on: ubuntu-24.04 @@ -67,5 +67,10 @@ jobs: - name: Run QUnit tests run: npm run grunt qunit:compiled - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code + - name: Check for uncommitted changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Uncommitted changes detected:" + git status --porcelain + exit 1 + fi diff --git a/.github/workflows/reusable-javascript-type-checking-v1.yml b/.github/workflows/reusable-javascript-type-checking-v1.yml index 9dabd01e27fa0..d1f484c39c36c 100644 --- a/.github/workflows/reusable-javascript-type-checking-v1.yml +++ b/.github/workflows/reusable-javascript-type-checking-v1.yml @@ -23,7 +23,7 @@ jobs: # - Configures caching for TypeScript build info. # - Runs JavaScript type checking. # - Saves the TypeScript build info. - # - Ensures version-controlled files are not modified or deleted. + # - Checks for any uncommitted changes. typecheck: name: Run JavaScript type checking runs-on: ubuntu-24.04 @@ -72,5 +72,10 @@ jobs: *.tsbuildinfo key: "ts-build-info-${{ github.run_id }}" - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code + - name: Check for uncommitted changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Uncommitted changes detected:" + git status --porcelain + exit 1 + fi diff --git a/.github/workflows/reusable-performance-test-v2.yml b/.github/workflows/reusable-performance-test-v2.yml index c0279c37fe64b..7bafb8fff4894 100644 --- a/.github/workflows/reusable-performance-test-v2.yml +++ b/.github/workflows/reusable-performance-test-v2.yml @@ -102,7 +102,7 @@ jobs: # - Install MU plugin. # - Run performance tests. # - Archive artifacts. - # - Ensure version-controlled files are not modified or deleted. + # - Checks for any uncommitted changes. performance: name: Test ${{ inputs.subject == 'base' && inputs.BASE_TAG || inputs.subject }} runs-on: ubuntu-24.04 @@ -272,5 +272,10 @@ jobs: if-no-files-found: error include-hidden-files: true - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code + - name: Check for uncommitted changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Uncommitted changes detected:" + git status --porcelain + exit 1 + fi diff --git a/.github/workflows/reusable-php-compatibility.yml b/.github/workflows/reusable-php-compatibility.yml index 7756330282e6f..ed7cf3abbfae2 100644 --- a/.github/workflows/reusable-php-compatibility.yml +++ b/.github/workflows/reusable-php-compatibility.yml @@ -30,7 +30,7 @@ jobs: # - Make Composer packages available globally. # - Runs the PHP compatibility tests. # - Generate a report for displaying issues as pull request annotations. - # - Ensures version-controlled files are not modified or deleted. + # - Checks for any uncommitted changes. php-compatibility: name: Run compatibility checks runs-on: ubuntu-24.04 @@ -86,5 +86,10 @@ jobs: if: ${{ always() && steps.phpcs.outcome == 'failure' }} run: cs2pr ./.cache/phpcs-compat-report.xml - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code + - name: Check for uncommitted changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Uncommitted changes detected:" + git status --porcelain + exit 1 + fi diff --git a/.github/workflows/reusable-phpstan-static-analysis-v1.yml b/.github/workflows/reusable-phpstan-static-analysis-v1.yml index 745e789580d8f..5fee27c7ab4ab 100644 --- a/.github/workflows/reusable-phpstan-static-analysis-v1.yml +++ b/.github/workflows/reusable-phpstan-static-analysis-v1.yml @@ -30,7 +30,7 @@ jobs: # - Make Composer packages available globally. # - Runs PHPStan static analysis (with Pull Request annotations). # - Saves the PHPStan result cache. - # - Ensures version-controlled files are not modified or deleted. + # - Checks for any uncommitted changes. phpstan: name: Run PHP static analysis runs-on: ubuntu-24.04 @@ -99,5 +99,10 @@ jobs: path: .cache key: "phpstan-result-cache-${{ github.run_id }}" - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code + - name: Check for uncommitted changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Uncommitted changes detected:" + git status --porcelain + exit 1 + fi diff --git a/.github/workflows/reusable-phpunit-tests-v2.yml b/.github/workflows/reusable-phpunit-tests-v2.yml index 5e078b6ef0c2e..21f71546bdb2d 100644 --- a/.github/workflows/reusable-phpunit-tests-v2.yml +++ b/.github/workflows/reusable-phpunit-tests-v2.yml @@ -84,7 +84,7 @@ jobs: # - Logs debug information from inside the WordPress Docker container. # - Install WordPress within the Docker container. # - Run the PHPUnit tests. - # - Ensures version-controlled files are not modified or deleted. + # - Checks for any uncommitted changes. test-php: name: PHP ${{ inputs.php }} / ${{ inputs.multisite && ' Multisite' || 'Single Site' }}${{ inputs.split_slow && ' slow tests' || '' }}${{ inputs.memcached && ' with memcached' || '' }} runs-on: ${{ inputs.os }} @@ -208,5 +208,10 @@ jobs: if: ${{ ! inputs.split_slow }} run: LOCAL_PHP_XDEBUG=true npm run "test:${PHPUNIT_SCRIPT}" -- -v --group xdebug --exclude-group __fakegroup__ - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code + - name: Check for uncommitted changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Uncommitted changes detected:" + git status --porcelain + exit 1 + fi diff --git a/.github/workflows/reusable-phpunit-tests-v3.yml b/.github/workflows/reusable-phpunit-tests-v3.yml index bcad042dfe559..81ce4acd3d54e 100644 --- a/.github/workflows/reusable-phpunit-tests-v3.yml +++ b/.github/workflows/reusable-phpunit-tests-v3.yml @@ -113,7 +113,7 @@ jobs: # - Install WordPress within the Docker container. # - Run the PHPUnit tests. # - Upload the code coverage report to Codecov.io. - # - Ensures version-controlled files are not modified or deleted. + # - Checks for any uncommitted changes. # - Checks out the WordPress Test reporter repository. # - Submit the test results to the WordPress.org host test results. phpunit-tests: @@ -268,8 +268,13 @@ jobs: flags: ${{ inputs.multisite && 'multisite' || 'single' }},php fail_ci_if_error: true - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code + - name: Check for uncommitted changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Uncommitted changes detected:" + git status --porcelain + exit 1 + fi - name: Checkout the WordPress Test Reporter if: ${{ github.ref == 'refs/heads/trunk' && inputs.report }} diff --git a/.github/workflows/reusable-test-core-build-process.yml b/.github/workflows/reusable-test-core-build-process.yml index 1566d1583a807..e767f9d80c306 100644 --- a/.github/workflows/reusable-test-core-build-process.yml +++ b/.github/workflows/reusable-test-core-build-process.yml @@ -54,10 +54,10 @@ jobs: # - Logs debug information about the GitHub Action runner. # - Installs npm dependencies. # - Builds WordPress to run from the desired location (src or build). - # - Ensures version-controlled files are not modified or deleted. + # - Checks for any uncommitted changes after building. # - Creates a ZIP of the built WordPress files (when building to the build directory). # - Cleans up after building WordPress. - # - Ensures version-controlled files are not modified or deleted. + # - Checks for any uncommitted changes after cleaning. # - Uploads the ZIP as a GitHub Actions artifact (when building to the build directory). # - Saves the pull request number to a text file. # - Uploads the pull request number as an artifact. @@ -69,6 +69,14 @@ jobs: timeout-minutes: 20 steps: + # Windows converts LF to CRLF on checkout. This makes every built file appear as modified because the build output + # will be CRLF. + - name: Configure Git line endings on Windows + if: ${{ contains( inputs.os, 'windows-' ) }} + run: | + git config --global core.autocrlf false + git config --global core.eol lf + - name: Checkout repository uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 with: @@ -119,8 +127,14 @@ jobs: - name: Build WordPress to run from ${{ inputs.directory }} run: npm run ${{ inputs.directory == 'src' && 'build:dev' || 'build' }} - - name: Ensure version-controlled files are not modified or deleted during building - run: git diff --exit-code + - name: Check for uncommitted changes after building + shell: bash + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Uncommitted changes detected:" + git status --porcelain + exit 1 + fi - name: Create ZIP of built files if: ${{ inputs.directory == 'build' && contains( inputs.os, 'ubuntu-' ) }} @@ -129,8 +143,14 @@ jobs: - name: Clean after building to run from ${{ inputs.directory }} run: npm run grunt ${{ inputs.directory == 'src' && 'clean -- --dev' || 'clean' }} - - name: Ensure version-controlled files are not modified or deleted during cleaning - run: git diff --exit-code + - name: Check for uncommitted changes after cleaning + shell: bash + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Uncommitted changes detected:" + git status --porcelain + exit 1 + fi - name: Upload ZIP as a GitHub Actions artifact uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1 diff --git a/.github/workflows/reusable-test-gutenberg-build-process.yml b/.github/workflows/reusable-test-gutenberg-build-process.yml index 4a780d08ee07f..ae5e4cd74d298 100644 --- a/.github/workflows/reusable-test-gutenberg-build-process.yml +++ b/.github/workflows/reusable-test-gutenberg-build-process.yml @@ -39,7 +39,7 @@ jobs: # - Installs Core npm dependencies. # - Builds WordPress to run from the relevant location (src or build). # - Builds Gutenberg. - # - Ensures version-controlled files are not modified or deleted. + # - Checks for any uncommitted changes after building. build-process-tests: name: ${{ contains( inputs.os, 'macos-' ) && 'MacOS' || contains( inputs.os, 'windows-' ) && 'Windows' || 'Linux' }} permissions: @@ -96,5 +96,11 @@ jobs: run: npm run build working-directory: ${{ env.GUTENBERG_DIRECTORY }} - - name: Ensure version-controlled files are not modified or deleted during building - run: git diff --exit-code + - name: Check for uncommitted changes after building + shell: bash + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Uncommitted changes detected:" + git status --porcelain + exit 1 + fi diff --git a/.github/workflows/reusable-test-local-docker-environment-v1.yml b/.github/workflows/reusable-test-local-docker-environment-v1.yml index 8f1a556afa2b4..50118d45045ee 100644 --- a/.github/workflows/reusable-test-local-docker-environment-v1.yml +++ b/.github/workflows/reusable-test-local-docker-environment-v1.yml @@ -71,7 +71,7 @@ jobs: # - Runs a WP CLI command. # - Tests the logs command. # - Tests the reset command. - # - Ensures version-controlled files are not modified or deleted. + # - Checks for any uncommitted changes. local-docker-environment-tests: name: ${{ 'mariadb' == inputs.db-type && 'MariaDB' || 'MySQL' }} ${{ inputs.db-version }}${{ inputs.memcached && ' with memcached' || '' }}${{ 'example.org' != inputs.tests-domain && format( ' {0}', inputs.tests-domain ) || '' }} permissions: @@ -166,5 +166,10 @@ jobs: - name: Reset the Docker environment run: npm run env:reset - - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code + - name: Check for uncommitted changes + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Uncommitted changes detected:" + git status --porcelain + exit 1 + fi diff --git a/.github/workflows/test-and-zip-default-themes.yml b/.github/workflows/test-and-zip-default-themes.yml index 1a44a8ff12e3a..d80a1d9731af2 100644 --- a/.github/workflows/test-and-zip-default-themes.yml +++ b/.github/workflows/test-and-zip-default-themes.yml @@ -112,7 +112,12 @@ jobs: # - Sets up Node.js. # - Installs npm dependencies. # - Runs the theme build script. - # - Ensures version-controlled files are not modified or deleted. + # - Checks for uncommitted changes. + # - Stages all uncommitted changes and adds any unversioned files. + # - Displays a diff of all staged changes. + # - Saves staged changes to a .diff file. + # - Uploads the diff file as an artifact. + # - Fails the job when uncommitted changes are detected. test-build-scripts: name: Test ${{ matrix.theme }} build script runs-on: ubuntu-24.04 @@ -156,23 +161,27 @@ jobs: - name: Build theme run: npm run build - - name: Check for changes to versioned files + - name: Check for uncommitted changes id: built-file-check if: ${{ github.event_name == 'pull_request' }} run: | - if git diff --quiet; then + if [ -z "$(git status --porcelain)" ]; then echo "uncommitted_changes=false" >> "$GITHUB_OUTPUT" else echo "uncommitted_changes=true" >> "$GITHUB_OUTPUT" fi - - name: Display changes to versioned files + - name: Stage all changes for diff generation if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }} - run: git diff + run: git add -A + + - name: Display all uncommitted changes + if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }} + run: git diff --cached - name: Save diff to a file if: ${{ steps.built-file-check.outputs.uncommitted_changes == 'true' }} - run: git diff > ./changes.diff + run: git diff --cached --binary > ./changes.diff # Uploads the diff file as an artifact. - name: Upload diff file as artifact @@ -183,12 +192,20 @@ jobs: path: src/wp-content/themes/${{ matrix.theme }}/changes.diff - name: Ensure version-controlled files are not modified or deleted - run: git diff --exit-code + run: | + if [ -n "$(git status --porcelain)" ]; then + echo "Uncommitted changes detected after build:" + git status --porcelain + exit 1 + fi # Prepares bundled themes for release. # # Performs the following steps: # - Checks out the repository. + # - Sets up Node.js. + # - Installs npm dependencies. + # - Runs the theme build script. # - Uploads the theme files as a workflow artifact (files uploaded as an artifact are automatically zipped). bundle-theme: name: Create ${{ matrix.theme }} ZIP file diff --git a/.gitignore b/.gitignore index 15876fa47fee8..5a7f9b5aef66e 100644 --- a/.gitignore +++ b/.gitignore @@ -48,6 +48,11 @@ wp-tests-config.php /artifacts /setup.log /coverage +/codecov +codecov.* +before.zip +wordpress.zip +wp-code-coverage-*.xml # Files and folders that get created in wp-content /src/wp-content/blogs.dir diff --git a/Gruntfile.js b/Gruntfile.js index 815ccce3af535..a06826cd9ee25 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -47,14 +47,23 @@ module.exports = function(grunt) { 'wp-includes/js/', ], - // All files copied from the Gutenberg repository excluded from version control. + // Unversioned files copied from the Gutenberg repository. gutenbergFiles = [ 'wp-includes/js/dist', 'wp-includes/css/dist', + 'wp-includes/images/icon-library', // Old location kept temporarily to ensure they are cleaned up. 'wp-includes/icons', ], + // Files copied from Gutenberg subject to version control. + gutenbergVersionedFiles = [ + 'wp-includes/images/icon-library', + 'wp-includes/build', + 'wp-includes/blocks/*', + '!wp-includes/blocks/index.php', + ], + // All files built by Webpack, in /src or /build. // Webpack only builds Core-specific media files and development scripts. // Blocks, packages, script modules, and vendors come from the Gutenberg build. @@ -245,6 +254,25 @@ module.exports = function(grunt) { gutenberg: gutenbergFiles.map( function( file ) { return setFilePath( WORKING_DIR, file ); }), + + /* + * Delete directories and files subjet to version control where the contents come from Gutenberg. + * + * This handles instances where a file remains present even after being deleted upstream. + * + * This task is intentionally skipped unless the current task will re-copy the corresponding files. + */ + 'gutenberg-versioned': { + filter: function() { + var allowedTasks = [ 'build', 'build:dev', 'build:gutenberg', 'clean:gutenberg-versioned' ]; + return allowedTasks.some( function( task ) { + return grunt.cli.tasks.indexOf( task ) !== -1; + } ); + }, + src: gutenbergVersionedFiles.map( function( file ) { + return setFilePath( SOURCE_DIR, file ); + } ), + }, dynamic: { dot: true, expand: true, @@ -666,7 +694,7 @@ module.exports = function(grunt) { 'constants.php', 'pages/**/*.php', ], - dest: WORKING_DIR + 'wp-includes/build/', + dest: SOURCE_DIR + 'wp-includes/build/', } ], }, /* @@ -683,7 +711,7 @@ module.exports = function(grunt) { expand: true, cwd: 'gutenberg/build', src: [], - dest: WORKING_DIR + 'wp-includes/build/', + dest: SOURCE_DIR + 'wp-includes/build/', }, 'gutenberg-js': { files: [ { @@ -692,7 +720,7 @@ module.exports = function(grunt) { src: [ 'pages/**/*.js', ], - dest: WORKING_DIR + 'wp-includes/build/', + dest: SOURCE_DIR + 'wp-includes/build/', } ], }, 'gutenberg-modules': { @@ -706,7 +734,7 @@ module.exports = function(grunt) { // with no debugging value over the minified versions. '!vips/!(*.min).js', ], - dest: WORKING_DIR + 'wp-includes/js/dist/script-modules/', + dest: SOURCE_DIR + 'wp-includes/js/dist/script-modules/', } ], }, 'gutenberg-styles': { @@ -719,7 +747,7 @@ module.exports = function(grunt) { // Per-block CSS is copied to wp-includes/blocks/ by tools/gutenberg/copy.js. '!block-library/*/**', ], - dest: WORKING_DIR + 'wp-includes/css/dist/', + dest: SOURCE_DIR + 'wp-includes/css/dist/', } ], }, 'gutenberg-theme-json': { @@ -738,11 +766,11 @@ module.exports = function(grunt) { files: [ { src: 'gutenberg/lib/theme.json', - dest: WORKING_DIR + 'wp-includes/theme.json', + dest: SOURCE_DIR + 'wp-includes/theme.json', }, { src: 'gutenberg/lib/theme-i18n.json', - dest: WORKING_DIR + 'wp-includes/theme-i18n.json', + dest: SOURCE_DIR + 'wp-includes/theme-i18n.json', }, ], }, @@ -751,7 +779,7 @@ module.exports = function(grunt) { expand: true, cwd: 'gutenberg/packages/icons/src/library', src: '*.svg', - dest: WORKING_DIR + 'wp-includes/images/icon-library', + dest: SOURCE_DIR + 'wp-includes/images/icon-library', } ], }, 'icon-library-manifest': { @@ -773,7 +801,7 @@ module.exports = function(grunt) { }, files: [ { src: 'gutenberg/packages/icons/src/manifest.php', - dest: WORKING_DIR + 'wp-includes/assets/icon-library-manifest.php', + dest: SOURCE_DIR + 'wp-includes/assets/icon-library-manifest.php', } ], }, }, @@ -1677,10 +1705,9 @@ module.exports = function(grunt) { grunt.registerTask( 'gutenberg:copy', 'Copies Gutenberg JS packages and block assets to WordPress Core.', function() { const done = this.async(); - const buildDir = grunt.option( 'dev' ) ? 'src' : 'build'; grunt.util.spawn( { cmd: 'node', - args: [ 'tools/gutenberg/copy.js', `--build-dir=${ buildDir }` ], + args: [ 'tools/gutenberg/copy.js' ], opts: { stdio: 'inherit' } }, function( error ) { done( ! error ); @@ -2157,6 +2184,9 @@ module.exports = function(grunt) { } ); grunt.registerTask( 'build:gutenberg', [ + 'gutenberg:verify', + 'clean:gutenberg-versioned', + 'clean:gutenberg', 'copy:gutenberg-php', 'routes:setup', 'copy:routes', @@ -2172,24 +2202,22 @@ module.exports = function(grunt) { grunt.registerTask( 'build', function() { if ( grunt.option( 'dev' ) ) { grunt.task.run( [ - 'gutenberg:verify', + 'build:gutenberg', 'build:js', 'build:css', 'build:codemirror', - 'build:gutenberg', - 'build:certificates' + 'build:certificates', ] ); } else { grunt.task.run( [ - 'gutenberg:verify', - 'build:certificates', + 'build:gutenberg', 'build:files', 'build:js', 'build:css', 'build:codemirror', - 'build:gutenberg', + 'build:certificates', 'replace:source-maps', - 'verify:build' + 'verify:build', ] ); } } ); diff --git a/tools/gutenberg/copy.js b/tools/gutenberg/copy.js index 8589c9581bed1..f6a24d2306db3 100644 --- a/tools/gutenberg/copy.js +++ b/tools/gutenberg/copy.js @@ -19,21 +19,10 @@ const rootDir = path.resolve( __dirname, '../..' ); const gutenbergDir = path.join( rootDir, 'gutenberg' ); const gutenbergBuildDir = path.join( gutenbergDir, 'build' ); -/* - * Determine build target from command line argument (--dev or --build-dir). - * Default to 'src' for development. - */ -const args = process.argv.slice( 2 ); -const buildDirArg = args.find( ( arg ) => arg.startsWith( '--build-dir=' ) ); -const buildTarget = buildDirArg - ? buildDirArg.split( '=' )[ 1 ] - : args.includes( '--dev' ) - ? 'src' - : 'build'; - -const wpIncludesDir = path.join( rootDir, buildTarget, 'wp-includes' ); +// All files handled in this script are subject to version control, so they should always be placed into src/. +const wpIncludesDir = path.join( rootDir, 'src', 'wp-includes' ); -/** +/* * Copy configuration. * Defines what to copy from Gutenberg build and where it goes in Core. */ @@ -508,7 +497,7 @@ function generateBlocksJson() { * Main execution function. */ async function main() { - console.log( `📦 Copying Gutenberg build to ${ buildTarget }/...` ); + console.log( '📦 Copying versioned Gutenberg files to src/...' ); if ( ! fs.existsSync( gutenbergBuildDir ) ) { console.error( '❌ Gutenberg build directory not found' );