webpack-cli
webpack-cli copied to clipboard
feat: autocomplete
What kind of change does this PR introduce? feature #1402
Did you add tests for your changes? No.
If relevant, did you update the documentation? No, it is pending.
Summary Introduces autocomplete feature for shell based command lines.
Does this PR introduce a breaking change? No
Other information You will have to run npm link in /packages/webpack-cli folder in order to test this feature. I am not sure how can I write tests, I need someone who can help me figure out.
Work needed (Need help from community for that) --> Write unit tests --> This PR as of now is just an autocomplete command setup, there is still need for add all the commands which are supported by webpack-cli. This can be done by updating autocompleteTree object in file /packages/webpack-cli/src/utils/autocomplete.ts --> Update Docs
The committers listed above are authorized under a signed CLA.
- :white_check_mark: login: HyperDanisH / name: Danish Arora (1d210b3769416b889a86f45b917ea1a2f96725fd, 2b887a7bd490b1203cbce567cd988f7ce7111f93, 4756a1e62e6acf3e5580b8c40e1987a118e8f806, aaed387fd47c28062af7bc9c25fa2b23a4cdd4ee, 39c4a4cd07ee86d147db3c67de7a799d30695d80, 8ab2c72da87c85180b794229f08f3e1355264d3c, 5b031f1f734dca49c9706d0794313817550db786, fbb165dfce54d9cef737aa233812595abaa71831, 2d5b9915ab9978f04f5840ec50d17f21c782e3e7, 5d15b765de71e59abfd495dc5250312c20d091e8, 33047cf398cdcc8520a7aa0f93dba3dcb6f3e4d9, 7f1b2ed67846a299c8eef638ceaf5dafffb79f64)
Can you provide steps how it can be used
/cc @webpack/cli-team Can anyone follow up on this development?
--> You should be in a shell supported command line. Window's Command Prompt if I recall is not in that list so this might not work there. If you are using WSL (Windows Subsystem for Linux) then it is definitely supposed to work.
-->Use npm link command in packages/webpack-cli folder. You can't use this feature by running node ./bin/cli.js command. Npm link is a must.
-->After linking run webpack-cli setup-autocomplete command. This is must in order to setup the autocomplete in user's shell based command line.
-->After this when you type webpack-cli and then press tab key on keyboard, It is supposed to give suggestions. As of now it only suggest one command but it is easy to setup others in no time by writting all the commands down at autocompleteTree object in file /packages/webpack-cli/src/utils/autocomplete.ts.
Hi @HyperDanisH.
Just a little hint from a friendly bot about the best practice when submitting pull requests:
Don't submit pull request from your own
masterbranch. It's recommended to create a feature branch for the PR.
You don't have to change it for this PR, just make sure to follow this hint the next time you submit a PR.
WIP. Not abandoned, just a little bit busy with the GSOC2024 application. Will continue to work on it asap.
@alexander-akait, I have come up with a way to finish autocomplete in webpack-cli. But the trade off is that there will be much refactoring needed to be done in the preexisting codebase. Am I allowed to do that. I thought I should ask before I put effort on that.
@HyperDanisH I don't think we really need to make these changes, there is commander API and you can get all commands and options there
What do you think about this? https://github.com/webpack/webpack-cli/issues/1402#issuecomment-2012132061.
After the latest commit in this PR, we can see autocomplete in action for all commands. all that left is getting the options from commander API and adding autocomplete support for them as well. and maybe some refactoring.