The CLI provides a powerful interface for interacting with your packages and repositories in Cloudsmith. However some operations currently require additional scripting to achieve the required result. Please see examples below:
Currently it is only possible to directly move one package at a time. However, it is easy to script a solution for moving multiple packages.
The following command will list all the packages returned by YOUR-QUERY. Extract the relevant metadata and run the copy command for each.
cloudsmith ls pkg YOUR-ACCOUNT/YOUR-REPO -q 'YOUR-QUERY' -F json | jq '.data | .namespace + "/" + .repository + "/" + .slug' -r | xargs -Ipackage cloudsmith copy package YOUR-DEST-REPO
The destination is not qualified by a namespace (YOUR-ACCOUNT). This is because you can only copy/move packages from repositories within the same namespace.
You can remove the query (YOUR-QUERY) to target all packages. The only downside to this approach is that it might require multiple invocations if you have more packages than the page size limit.
It's possible to navigate pages using -p and increase the page size limit to 500 using -l 500
The following moves all Maven packages named cloudsmith-api with version 0.21.* from lskillen/test2 to lskillen/test3. (Permissions permitting obviously)
cloudsmith ls pkg lskillen/test2 -q 'format:maven AND name:cloudsmith-api AND version:^0.21' -F json | jq '.data | .namespace + "/" + .repository + "/" + .slug' -r | xargs -Ipackage cloudsmith copy package test3
Updated 11 months ago