Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[@faustwp/cli] Bug: fetchBlockFiles returns empty Array while running faust blockset on Windows #1804

Open
1 task done
floretsky opened this issue Feb 15, 2024 · 1 comment
Labels
bug good first issue needs reproduction This issue needs a reproduction in order for the team to investigate further

Comments

@floretsky
Copy link

floretsky commented Feb 15, 2024

Description

Hello!

I have been running faust blockset command and every time my .faust folder would only contain these files:

├── .faust
│   ├── blocks
│   │   ├── manifest.json
│   ├── build
│   │   ├── MyCustomBlock
│   │   │   ├── block.json
│   │   │   ├── index.asset.php
│   │   │   ├── index.js
│   │   │   ├── index.js.map
│   ├── blocks.zip

block.zip only contains manifest.json with this kind of data:

{
  "blocks": [],
  "timestamp": "2024-02-15T17:42:51.653Z"
}

I have been doing some discovery on why this happens and discovered that the issue lies in this function:
\node_modules@faustwp\cli\dist\blockset.js:53

/**
 * Fetches paths to all block.json files while ignoring node_modules.
 *
 * @returns {Promise<string[]>} - An array of paths to block.json files.
 */
export async function fetchBlockFiles() {
    return glob(`${FAUST_BUILD_DIR}/**/block.json`, {
        ignore: IGNORE_NODE_MODULES,
    });
}

FAUST_BUILD_DIR contained the path to Faust Build folder in the Windows format ( \project-name.faust\ ) and based on what I researched, a glob pattern should be in POSIX format. (//). Since glob could not process this path correctly, fetchBlockFiles() would always return empty array.

I have fixed it in my local environment by formatting FAUST_BUILD_DIR with .replace(/\\/g, '/') and faust blockset has started to perform the script and detect blocks correctly

Steps to reproduce

  1. Clone the faustwp-getting-started example project
  2. "blockset": "faust blockset" in the package.json
  3. npm run blockset
  4. The blocks generated by @faustwp/blocks would not appear in WP, .faust/blocks folder only contains manifest.json with blocks: [], .zip archive only contains manifest.json

Additional context

No response

@faustwp/core Version

2.1.2

@faustwp/cli Version

2.0.0

FaustWP Plugin Version

1.2.1

WordPress Version

6.4.3

Additional environment details

@faustwp/blocks: 2.0.0
Windows 11 Home Version 22H2

Please confirm that you have searched existing issues in the repo.

  • Yes
@theodesp
Copy link
Member

Hey @floretsky thank you for the report. Would you be able to provide a PR for this?

@mindctrl mindctrl added bug needs reproduction This issue needs a reproduction in order for the team to investigate further labels Feb 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug good first issue needs reproduction This issue needs a reproduction in order for the team to investigate further
Projects
None yet
Development

No branches or pull requests

3 participants