Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,13 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [0.10.7] - Unreleased

### Added
- #992: Implement automatic history purge logic
- #973: Enables CORS and JWT configuration for WebApplications in module.xml
- #1079: add semantic sorting and shortcuts to list-installed

### Fixed
- #1001: The `unmap` and `enable` commands will now only activate CPF merge once after all namespaces have been configured instead after every namespace
Expand Down
50 changes: 50 additions & 0 deletions src/cls/IPM/Main.cls
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,17 @@ reinstall -env /path/to/env1.json;/path/to/env2.json example-package
list -python
</example>

<example description="Shortforms: n, d, v. Add '-d' for descending (e.g., d-d).">
list -s [name|date|version]
</example>

<example description="Shows installed modules in descending order">
list -s name-desc
</example>
<example description="Shows installed modules in decending based on the installation date">
list -s d-d
</example>

<!-- Parameters -->
<parameter name="searchString" description="Search string, * can be used." />

Expand All @@ -538,6 +549,7 @@ reinstall -env /path/to/env1.json;/path/to/env2.json example-package
<modifier name="showupstream" aliases="su" description="If specified, show the latest version for each module in configured repos if it's different than the local version." />
<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="sort" aliases="s" value="true" description="Sort the list. Options: name, name-desc, date, date-desc, version, version-desc" />
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Default sort (if flag not provided) should be ascending by name. Should indicate that here.

</command>

<command name="list-dependents" aliases="dependents">
Expand Down Expand Up @@ -2809,6 +2821,44 @@ ClassMethod ListInstalled(ByRef pCommandInfo) [ Private ]
}
}
merge tModifiers = pCommandInfo("modifiers")
set sortMode = $$$lcase($get(pCommandInfo("modifiers", "sort")))

if sortMode'="" {
set newlist =""
set type = $extract(sortMode, 1) // "d", "n", or "v"
set isDesc = (sortMode [ "-d")
set sortMode = $case(type, "n":"name", "d":"date", "v":"version", :"name")
if isDesc {
set sortMode = sortMode_"-desc"
}
for i=1:1:list {
set entry = list(i)
set name = $listget(entry,1)
set entry = entry_$listbuild(i)
if sortMode["name"{
set newlist($$$lcase(name),i)=entry
} elseif sortMode["date" {
set date = $listget(entry,6)
set newlist(date,name) = entry
} elseif sortMode["version" {
set newlist($listfromstring($listget(entry,2),"."),name) = entry
}
kill list(i)
}
set direction = $select(sortMode [ "desc": -1, 1: 1)
set sub = ""
if $data(newlist)>1 {
// create new list based on the sorting
for {
set sub = $order(newlist(sub),direction) quit:sub=""
set mod=""
for {
set mod = $order(newlist(sub,mod),direction,data) quit:mod=""
set list($increment(mlist))=data
}
}
}
}
do ..DisplayModules(.list,,,, .tModifiers)
}
}
Expand Down
2 changes: 0 additions & 2 deletions src/cls/IPM/Storage/QualifiedModuleInfo.cls
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ Method %OnNew(
set ..Version = pResolvedReference.Version
set ..Deployed = pResolvedReference.Deployed
set ..PlatformVersions = pResolvedReference.PlatformVersions
set ..VersionString = pResolvedReference.VersionString
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like a mistake in merging from main. These should not be removed.

set ..AllVersions = pResolvedReference.AllVersions
}
quit $$$OK
}
Expand Down
12 changes: 12 additions & 0 deletions tests/unit_tests/Test/PM/Unit/CLI.cls
Original file line number Diff line number Diff line change
Expand Up @@ -352,4 +352,16 @@ Method TestUninstallWithoutModuleName()
do $$$AssertNotTrue(exists, "Module removed successfully.")
}

Method TestListSortingFlags()
{
do $$$LogMessage("Testing list-installed sorting flags")
set status = ..RunCommand("list")
set status = ..RunCommand("list -s n")
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests should read output and confirm its sorted in the correct order. Should also test ascending and descending for each sort modifier

do $$$AssertStatusOK(status, "Sort by name command executed successfully")
set status = ..RunCommand("list -s v-d")
do $$$AssertStatusOK(status, "Sort by version descending executed successfully")
set status = ..RunCommand("list -s d-d")
do $$$AssertStatusOK(status, "Sort by date descending executed successfully")
}

}