DanHulton / oclif-dynamic-commands

oclif plugin that loads commands dynamically from a directory.
MIT License
1 stars 0 forks source link

Is this currently working? #1

Open FRANK-AND-FREE opened 7 months ago

FRANK-AND-FREE commented 7 months ago

Hi @DanHulton, this is not exactly a bug report, since I can't guarantee that something is wrong with the plugin. I've been trying to get the plugin working for days now with a CLI that I created with the current OCLIF version. I have added the oclif-dynamic-commands plugin according to your readme. The dependencies are all there in the node_modules folder.

I have published my CLI to an in-house NPM server of my company and installed it from there globally (npm install -g my-new-cli) on my machine. All the commands that come directly with my CLI are recognized, but when I call the CLI in a repository with commands that are meant to be loaded dynamically, they are not found. I'm pretty sure that I have configured the repository's package.json correctly in terms of pointing to the folder with the dynamic commands (*.ts files).

I could find out that the CLI seems to recognize the dynamic commands plugin, as the command to list the installed plugins tells me that the plugin in installed. Furthermore, if I manipulate the oclif.manifest.json file in the oclif-dynamic-commands folder that resides inside the node_modules folder of my CLI's global installation, by adding some command definitions. They will show up when I call my CLI, so my CLI does somehow interact with the dynamic commands plugin. The problem seems to be the part where dynamic commands are read from the current working directory.

This could still be an issue specific to my machine (a Windows computer, by the way) or a misconfiguration on my side, so I just wanted to ask if you are sure the plugin should still work with the latest version of OCLIF?

Best Frank

DanHulton commented 4 months ago

Apologies, I'm only just seeing this now.

Please try two things for me:

1) Try with a dynamic command that is stripped down to the bare minimum - only a console.log('hello') in the run() function. I have sometimes had issues with there being something wrong with the command (import issue, syntax issue, even a bug that should show up in the output) and it not actually showing what's wrong in the output, it just says that it can't find the command instead. If the bare-minimum command works, try gradually adding code from your commands until it doesn't work again, and that should point the way to what needs to be done.

2) Please attempt to run the command with DEBUG=* prepended to the command string, and paste the result (with sensitive info redacted) here. There might be more hints available in the debug logic.