Need help with `bit add` for nested components


#1

Hi, I’m new to Bit, and i want to add components from my project. I am having some difficulty getting it to work with the project structure for a react app. would it be possible to please ask what you suggest?

Attached is a mock of the project structure

can you please help me with the add command?


#2

From the example you attached, I assume you tried to run a command similar to this: bit add src/components/**/**/*.
Bit can’t handle it out of the box (even with the {FILE_NAME} and {PARENT} variables), because it does not know how to resolve the names of the components in a deterministic matter. This is because for Bit there are two dynamically named directories.

As a quick workaround, until we figure out a better solution for such structures, I suggest running a single command for each of the ‘main’ components (3, in this example) in the src/components directory. For example:

bit add src/components/text/ *-t 'src/components/paragraph/{PARENT}/*.test.js' -m 'src/components/paragraph/{PARENT}/{PARENT}.js'

Please let me know if this workaround works for you.