-
-
Notifications
You must be signed in to change notification settings - Fork 610
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
feat: autocomplete #4109
feat: autocomplete #4109
Conversation
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. |
{ | ||
long: "--stats", | ||
}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can get them, we already has logic where store all commands and flags
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That will definitely make things more easy and maintainable. Please tell me how to get them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://github.com/webpack/webpack-cli/blob/master/packages/webpack-cli/src/webpack-cli.ts#L1160
You can move them to the static helper, please study the code before you start working on it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure where can I find static helper methods. Do they exist? I seem to have not seen them in project. My apologies if I am asking a dumb doubt. I just not want things to break at all.
Hi @HyperDanisH. Just a little hint from a friendly bot about the best practice when submitting pull requests:
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? #1402 (comment). |
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. |
package.json
Outdated
@@ -89,6 +89,7 @@ | |||
"sass-loader": "^13.0.2", | |||
"strip-ansi": "^6.0.1", | |||
"style-loader": "^3.3.1", | |||
"test-package": "^0.0.1", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why we need it?
}); | ||
|
||
return autocompleteTree; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's make these function as a static method for webpack-cli class, it can be used for other features
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@HyperDanisH could you rebase?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you rebase?
On it |
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