feat(cli): ask to override files#475
Conversation
|
Hey @fecony, just tool a deeper look at your code and I have some thoughts/ideas/suggestions:
What do you think? Maybe there's a better place to put the checks, but I'd definitely avoid doing it explicitly in the commands. |
|
Hey, @javiertoledo.
Now it will check if resource exists and print info message about it before printing prompt or generation text. |
javiertoledo
left a comment
There was a problem hiding this comment.
Good work! The code is looking great, the only thing I'm missing is unit tests checking that the prompt is printed when a file exists and what happens when the user chooses to override or cancel the action. Once we merge #476, we could come back to this and implement a couple of integration tests too. Thanks a lot!
|
@javiertoledo Yep, #476 with it edit: Need to update docs too. There was something about files being removed. |
|
@javiertoledo Hey! I started to work with unit tests and I am confused with The problem is, it copies I am not sure if it was planned to use Let me know if I am wrong and should not use it in unit tests. Also if it is the case maybe you can tell me what exactly I should test in unit tests? 🤔 |
|
@fecony yes, the |
NickSeagull
left a comment
There was a problem hiding this comment.
Lovely, thanks for this! The only thing I'm missing is what @javiertoledo pointed :D
alvaroloes
left a comment
There was a problem hiding this comment.
@fecony Love the PR! Thanks a lot for this. Once you have the unit test in place (those Javi mentioned) and checked that the documentation is updated, this PR is good to go. Pre-approving!
|
@davidverdu, @javiertoledo, uff, I tried to write tests last time in november... I may try to write tests on this weekend. If you didn't decide to take take care of this PR 😄 |
a56b647 to
cbf508f
Compare
|
@davidverdu, @javiertoledo rebased & added unit tests! |
Hi @fecony there is a unit test which is failing. Could you review it? If you need help let us know. To run the unit tests just type |
|
Hey, @davidverdu fixed unit tests 📦 |
Thank you so much @fecony . However, the integration tests, which are run with In A similar change is needed in the file Another thing you need to do is to rebase again with main, since we have added new lines of code. Integration tests must work properly before accepting the PR. Thank you, you are almost ready for merge! |
davidverdu
left a comment
There was a problem hiding this comment.
Integration tests need to be fixed. I left a commend with instructions to solve the problem
…o feat/overriding_files

Description
Check if project folder or resource already exist before generating new file. It will ask user if he wants to override existing file and continue or stop generating. If user agrees to override it file/project folder is removed. If declines then it will throw error for user to use different resource name. (See Images below)
Closes #305
Changes
projectDir()checkProjectAlreadyExists()to check if project already exists in current directory.checkResourceExists()to check if resource already exists.checkProjectAlreadyExists()andcheckResourceExists()methodsconfirmPrompt()which is used bycheckProjectAlreadyExists()andcheckResourceExists()to reuse same codefilePathfunction which was used in single method, to get path where resource should be generated. Is used for generation and to check if resource existsFileDirtype forfilePathmethod to pick only required params'placementDir' | 'name' | 'extension'getResourceType()to get resource name from path.Checks
Additional information