Make WordPress Core

Opened 10 months ago

Closed 10 months ago

Last modified 9 months ago

#64559 closed defect (bug) (fixed)

Build: copyBlockAssets fails when core block types directories contain subdirectories

Reported by: mcsf Owned by: mcsf
Priority: normal Milestone: 7.0
Component: General Version:
Severity: normal Keywords: has-patch
Cc: Focuses:

Description (last modified by mcsf)

Issue first described at ​https://github.com/WordPress/gutenberg/pull/74805#issuecomment-3800272544

Follow-up of #64393

Steps to reproduce:

  • In package.json, change .gutenberg.ref to a recent Gutenberg hash (e.g. 2654e7d13086e483855cedf089ba6f4e86c967d7)
  • Run npm run build:dev
  • See the "Copying blocks..." step fail as it tries to copy a directory using fs.copySync:
Unexpected error: Error: ENOTSUP: operation not supported on socket, copyfile 'wordpress-develop/gutenberg/build/scripts/block-library/navigation-link/shared' -> 'wordpress-develop/src/wp-includes/blocks/navigation-link/shared'
    at Object.copyFileSync (node:fs:3085:11)
    at copyBlockAssets (wordpress-develop/tools/gutenberg/copy-gutenberg-build.js:231:9)

Fix:

Let fs.cpSync handle the entire recursive copy.

Change History (6)

This ticket was mentioned in ​PR #10805 on ​WordPress/wordpress-develop by ​@mcsf.


10 months ago
#1

  • Keywords has-patch added

See https://core.trac.wordpress.org/ticket/64559

Issue first described in ​https://github.com/WordPress/gutenberg/pull/74805#issuecomment-3800272544

Replace manual file iteration via fs.cpSync — which didn't support unexpected nested directories in block types' source dirs — with fs.cpSync.

#2 @mcsf
10 months ago

  • Description modified (diff)

​@youknowriad commented on ​PR #10805:


10 months ago
#3

Replace manual file iteration via fs.cpSync — which didn't support unexpected nested directories in block types' source dirs — with fs.cpSync.

Do we want to support these random folders or only keep block types folders? AFAIK, this is the first time we do this right?

​@mcsf commented on ​PR #10805:


10 months ago
#4

Do we want to support these random folders or only keep block types folders?

This is the choice I gave in ​https://github.com/WordPress/gutenberg/pull/74805#issuecomment-3800272544. My opinion is that it's not copyBlockAssets's job to have an opinion, and it certainly shouldn't fail. So:

  • copyBlockAssets should either copy or ignore (but not fail) folders
  • a discussion about conventions on dir structure, if desired, should happen in Gutenberg

AFAIK, this is the first time we do this right?

Yes and no. It's definitely not the first time we've added a directory under a block type:

$ find packages/block-library/src \
        -mindepth 2 -maxdepth 2 \
        -type d \
        -not -path '*/test' \
        -not -path '*/test/*'

packages/block-library/src/comments/edit
packages/block-library/src/navigation-link/link-ui
packages/block-library/src/navigation-link/shared
packages/block-library/src/file/utils
packages/block-library/src/navigation/utils
packages/block-library/src/navigation/edit
packages/block-library/src/template-part/edit
packages/block-library/src/social-link/icons
packages/block-library/src/list-item/hooks
packages/block-library/src/query/edit
packages/block-library/src/terms-query/edit
packages/block-library/src/cover/edit

But it is the only one ending up in the build artefacts:

$ find build/scripts/block-library \
        -mindepth 2 -maxdepth 2 \
        -type d

build/scripts/block-library/navigation-link/shared

#5 @mcsf
10 months ago

  • Owner set to mcsf
  • Resolution → fixed
  • Status new → closed

In 61567:

Build: Fix copyBlockAssets's handling of folders.

When copying block-type assets from Gutenberg to Core, use Node's fs.cp
instead of fs.copy. The former has much better semantics for wholesale
copies.

Fixes build failures arising from the introduction of subdirectories in the
source directories of certain core block types.

Reviewed by youknowriad.

Fixes #64559.

#6 @sabernhardt
9 months ago

  • Milestone Awaiting Review → 7.0
Note: See TracTickets for help on using tickets.