Page MenuHomeSealhub

Add CLI command that helps ensure that a particular module's subdirectory is present in controllerDirs
Open, Very HighPublic1 Points

Description

When writing a module that is a dependency for a Sealgen app, it would be useful (or even necessary) for the project that is using that module to know where to look for the stimulus controllers defined within that module.

This can be solved with a new sealgen CLI command:

npx sealgen register-external-controllers my_module_name src/stimulus-controllers

Running this should check if the path node_modules/${my_module_name}/src/stimulus-controllers is already present in the current project's package.json at the sealgen.controllerDirs array. If it's not, it should edit the package.json file and add that path to the array (create the array if it doesn't exist).

What's important is that if this command gets run in the root of the my_module_name, it should traverse the directory tree up to find the project that's using my_module_name and edit the package.json file in that parent project, not in my_module_name.

Then, one could just add the npx sealgen register-external-controllers (...) script to postinstall script in the package.json of the external module and it would automatically add the necessary information to the project once the dependency is added to the project.

Also, implement a similar functionality for the "styleDirs" attribute.