feat(cli): add -outdated modifier in list command#1095
feat(cli): add -outdated modifier in list command#1095AshokThangavel wants to merge 5 commits intointersystems:mainfrom
Conversation
- Implement '-outdated' (alias '-o') to filter for modules with updates. - Update CLI help text with descriptions and usage examples.
src/cls/IPM/Main.cls
Outdated
| } | ||
| } | ||
|
|
||
| ClassMethod GetOutdatedModulesList(Output List) |
There was a problem hiding this comment.
Does this also check if the new versions satisfy the existing version constraints? If not, it should.
For example, if we have module-a that depends on module-b ^1.3.0, and the available versions of module-b are 1.3.0 and 2.0.0, then list -outdated should not include module-b since 2.0.0 cannot be installed anyway.
There was a problem hiding this comment.
Hi @isc-dchui
Thank you for pointing out this excellent case. Currently, the check only determines whether a newer version exists and does not verify whether that version satisfies the existing version constraints.
So, in this scenario, module-b is not a directly installed module; it is installed as a dependency of module-a. Because of that, it likely should not appear in the list -outdated output.
Thank you!
There was a problem hiding this comment.
Ok! Let's add a test to make sure this works! (Also you have some failing tests)
There was a problem hiding this comment.
sure. Thank you!
There was a problem hiding this comment.
Hi @isc-dchui Thanks for pointing that out. Since the irisjwt module cannot be resolved from the external registry in CI, Could you suggest the best way to utilize local custom modules as test assets to bypass the registry requirement?
Thank you!
There was a problem hiding this comment.
Hi @isc-dchui
I’ve implemented the -outdated flag to skip modules installed only as dependencies. Thank you!
There was a problem hiding this comment.
The simplest would probably be adding the test modules to the Integration/_data directory and setting up a filesystem repo to point to it like so:
repo -fs -name local -path /home/irisowner/zpm/tests/integration_tests/Test/PM/Integration/_data/<dtest_directory>
There was a problem hiding this comment.
Thank you for the suggestion. Setting up a filesystem repository is a new configuration for me. Could you please point me toward the official documentation or a guide for this? That would be very helpful for my setup.
There was a problem hiding this comment.
There isn't much, but here's an example in the wiki:
https://github.com/intersystems/ipm/wiki/02.-CLI-commands#repo
isc-dchui
left a comment
There was a problem hiding this comment.
Two little nits and a suggestion for the testing
src/cls/IPM/Main.cls
Outdated
| { | ||
| do ..GetListModules($namespace,,.installedModules) | ||
| // Get the dependencies list to prevent displaying an outdated list | ||
| set List="" |
There was a problem hiding this comment.
Nit: make "List" lowercase
There was a problem hiding this comment.
changed to lowercase.
src/cls/IPM/Main.cls
Outdated
| <modifier name="repository" aliases="repo" value="true" description="If specified, only show modules installed that belong to the provided repository." /> | ||
| <modifier name="python" aliases="py" description="If specified, lists installed Embedded Python libraries instead of IPM modules." /> | ||
| <modifier name="outdated" aliases="o" description="Lists installed modules that have available updates in the registry." /> | ||
| <modifier name="outdated" aliases="o" description="If specified, only lists installed modules that have available updates in the registry. Modules installed only as dependencies are skipped." /> |
There was a problem hiding this comment.
Nit: I would reword this by removing the "only" from the second sentence, i.e. " Modules installed as dependencies are skipped"
There was a problem hiding this comment.
Updated the description. Thank you!
isc-kiyer
left a comment
There was a problem hiding this comment.
@AshokThangavel Looks good! Few small comments
| set moduleName = $listget(moduleInfo) | ||
|
|
||
| // Skip processing if the module is a dependency module | ||
| if moduleName="zpm"||($data(visitedMap(moduleName))) { |
There was a problem hiding this comment.
Skipping of dependencies should be an optional flag. The default should be to list all outdated modules in the namespace.
| set reg = $order(serverModuleVersions(moduleName,""),1,versionString) | ||
| if currentVersion'=versionString { | ||
| set currentwidth = $length(moduleName) | ||
| set list($increment(list)) = $listbuild(moduleName,$$$FormattedLine($$$Red, currentVersion)_" "_$$$FormattedLine($$$Green,versionString)) |
There was a problem hiding this comment.
Similar to npm outdated, it would be great to show both the highest version available on the current major version and the highest version available overall.
| } | ||
| if $data(pCommandInfo("modifiers","outdated")) { | ||
| merge tModifiers = pCommandInfo("modifiers") | ||
| do ..GetOutdatedModulesList(.list) |
There was a problem hiding this comment.
It would be nice for the list to have column headers to display
| /// Validates that the '-outdated' modifier correctly identifies and displays modules with newer registry versions | ||
| Method TestListOutdatedModules() | ||
| { | ||
| set moduleName = "irisjwt" |
There was a problem hiding this comment.
Should probably add a test with more than one module and one with dependencies.
Description:
Introduced the
-outdatedmodifier (alias-o) to thelistcommand to allow users to quickly identify installed modules with newer versions available in the registry.#586
Key Changes:
-outdatedand the short-form alias-oto thelist-installedcommand logic.CLI Documentation Update:
-outdated, -olist -outdatedTesting Performed:
list -oand verified that only modules with pending updates are displayed.Module : OldVersion NewVersion).