-
Notifications
You must be signed in to change notification settings - Fork 24
fix(cli): require module name for uninstall #1018
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
base: main
Are you sure you want to change the base?
fix(cli): require module name for uninstall #1018
Conversation
isc-kiyer
left a comment
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.
@AshokThangavel Looks good! Few minor comments. Also, this needs a changelog update
src/cls/IPM/Main.cls
Outdated
| set tModuleName = pCommandInfo("parameters","module") | ||
| set tModuleName = $get(pCommandInfo("parameters","module")) | ||
| if (tModuleName = "") { | ||
| $$$ThrowOnError($$$ERROR($$$GeneralError, "Module name is required for uninstall.")) |
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.
Nit: add to the message "when not using the -all flag"
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.
Yes, I’ve added a comment at the top of the code to address this.
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.
Adding it to the error message itself would also be handy (and I think what @isc-kiyer meant)
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.
Thank you. I've updated the error message to be more descriptive: A module name must be specified for uninstall unless the -all flag is used
| Method TestUninstallWithoutModuleName() | ||
| { | ||
| do $$$LogMessage("Run Uninstall command with out module name") | ||
| do ..RunCommand("unsintall") |
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.
This should check appropriate error was thrown
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.
Thank you! I've updated the code based on the comments
| do ..RunCommand("uninstall objectscript-math") | ||
| set exists = ##class(%IPM.Storage.Module).NameExists("objectscript-math") | ||
| do $$$AssertNotTrue(exists, "Module removed successfully.") | ||
| quit $$$OK |
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.
Nit: no need for a quit at the end
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.
Thank you! Removed the "quit" from the code
| do $$$LogMessage("Run Uninstall command with out module name") | ||
| do ..RunCommand("unsintall") | ||
| do ..RunCommand("install objectscript-math") | ||
| set exists = ##class(%IPM.Storage.Module).NameExists("objectscript-math") |
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.
Nit: fix spacing on this line
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.
Sure, I’ve fixed the spacing on that line.
src/cls/IPM/Main.cls
Outdated
| set tModuleName = pCommandInfo("parameters","module") | ||
| set tModuleName = $get(pCommandInfo("parameters","module")) | ||
| if (tModuleName = "") { | ||
| $$$ThrowOnError($$$ERROR($$$GeneralError, "Module name is required for uninstall.")) |
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.
Adding it to the error message itself would also be handy (and I think what @isc-kiyer meant)
| } | ||
|
|
||
| Method RunCommand(pCommand As %String) | ||
| // This method returns the %Status for checking the success or failure of executed commands. |
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.
Nit: method commands should use three slashes, not two
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've updated to three slashes
|
|
||
| Method TestUninstallWithoutModuleName() | ||
| { | ||
| do $$$LogMessage("Run Uninstall command with out module name") |
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.
Nit typo: "without" and not "with out"
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.
Thank you! fixed the typo
Description
This PR resolves an issue where the
uninstallcommand would proceed without a module name. In such cases, the command would default to the "implicit context" (the last active module), leading to accidental uninstallation of applications.fixes: #1017
Verification Results
Unit Test Passed:
TestUninstallWithoutModuleNameuninstall(no args) now returns aNotOKstatus.uninstall <name>still functions correctly.