Update Packages via Gitify?
Is there a reason why there is no package:upgrade command? Is it complicated to add for some reason? Otherwise we can Crowfound this feature to make it happen 😸
Hi @jenswittmann , this is already available as a hidden feature :) If you run package:install --all again, Gitify will attempt to install the latest version of each package, or the version specified. It will do nothing if the same version is already installed.
(You can specify a version in the package list, by appending it to the package name: - collections-4.1.1-pl etc..)
@hugopeek are you sure about that? I have some package updates in the manager. When I run package:install --all, a green message saying "Done!" appears, but nothing is updated. I know the command for a clean install.
@jenswittmann That doesn't sound right, if it skips directly to Done.. It should evaluate each package and notify you about its status, even if it won't upgrade anything. Typical output should look something like:
$ gitify package:install --all
Searching modx.com for collections...
Found 1 package(s).
Package Collections 4.1.1 is already installed.
Searching modx.com for formit...
Found 1 package(s).
Package FormIt 5.1.1 is already installed.
Searching modx.com for getcache...
Found 1 package(s).
Package getCache 1.1.0 is already installed.
And in .gitify:
packages:
modx.com:
service_url: 'https://rest.modx.com/extras/'
packages:
- collections
- formit
- getcache
Thanks for the help, @hugopeek! I tried adding VersionX via .gitify and then running gitify package:install --all. It installed VersionX. However, it doesn't update the other packages.
I also tried running the same thing on a web server to see if the problem was localised. Same result.
Which version of Gitify did you run?
Hmm, that does ring a bell, that it skips updating other packages. It was introduced here: https://github.com/modmore/Gitify/pull/430
Also update the package:install command to skip installing if an exact version match or a higher version of a package is already installed. This speeds it up a lot when there is nothing to update.
That would suggest that the behaviour you are seeing is correct, and that something is off on my side.. I am on the latest version however, 2.1.0-pl. Strange!
Anyway, for this issue: what happens if you specify a package in .gitify with an old version number, then run package install --all, and then bump the version number and run it again? Does it upgrade this specific package then? Or is it skipped also?
And which MODX / PHP version are you on?
Ah, I was testing this on a local install, which had the packages installed with the --local flag. This means they have no package provider, and then it apparently still checks for updates for each package. When testing with regular packages, they are skipped as described.
I am however still able to update packages by running package:install --all. Here, SuperBoxSelect is updated:
$ gitify package:install --all
Searching modx.com for superboxselect-3.1.2-pl...
Found 1 package(s).
Downloading SuperBoxSelect (3.1.2)...
Installing SuperBoxSelect...
{errors removed...}
Done!
When I run it again at this point, the update is skipped. But when I uninstall the package again in MODX and rerun package install --all, package is installed again. It doesn't matter if I specify a version number in .gitify or not.
Make sure to also remove any downloaded transport packages in MODX, because Gitify seems to be looking at that version number, even when it is not yet installed!
If it's still not working for you: what is the output if you run package:install --all --verbose?
Hej @hugopeek,
what happens if you specify a package in .gitify with an old version number, then run package install --all, and then bump the version number and run it again? Does it upgrade this specific package then? Or is it skipped also?
I added superboxselect-3.1.0-pl to .gitify. Then I ran gitify package:install --all and Gitify installed it as desired:
Searching modx.com for superboxselect-3.1.0-pl...
Found 1 package(s).
Downloading SuperBoxSelect (3.1.0)...
Installing SuperBoxSelect...
Greife auf Package-Workspace zu …
Workspace-Umgebung eingerichtet, installiere jetzt das Package …
System event "OnSuperboxselectTypeOptions" was created.
Done!
When I run gitify package:install --all -v again, it also skips as desired.
- superboxselect-3.1.0-pl is already installed, skipping
Done!
Then I removed the version number (superboxselect-3.1.0-pl > superboxselect) from .gitify and run gitify package:install --all -v again:
- superboxselect, found higher version 3.1.0-pl already installed
Done!
And which MODX / PHP version are you on?
Gitify 2.1.0-pl, MODX 3.1.0-pl and PHP 8.3.14.
But when I uninstall the package again in MODX and rerun package install --all, package is installed again. It doesn't matter if I specify a version number in .gitify or not.
Yes, this is the standard way to install a package for the first time.
I think gitify package:install should be used for a fresh installation of newly added packages. To update MODX, run gitify modx:upgrade followed by gitify package:upgrade. This should be the easiest method?
Another thing to note is that when you run gitify extract, .gitify is overridden by default and all packages are given a version number. This means that Gitify doesn't know if it has to lock on this version number or use a new one, which is fine. However, when you use gitify package:upgrade, it's clear that you want the latest version.
I don't think package:install --all will work here.
If no version is specified for a package in the ".gitify" file, then the code will only check if any version of this package is already installed. If a version is specified (for a package in the ".gitify" file), the code checks if the installed version (of the package) is equal or higher than the specified version.
There is no check at all, if a newer version of this package exists on the package provider.
How should the proposed package:upgrade command work?
Take all the packages listed in the ".gitify" file and check if a newer version exists on the package provider? Or only do a check for packages without a specified version?
What should happen if no version of a particular package is already installed on the MODX installation?
Hej @halftrainedharry, thank you for clarifying that.
How should the proposed package:upgrade command work? Take all the packages listed in the ".gitify" file and check if a newer version exists on the package provider?
Yes, it should work in the same way as clicking the Update button in the Manager.
But first, let's go back to my initial question. I think there is no gitify package:upgrade because nobody has written the code for it. Thank you, @halftrainedharry for the PR! I tested it, and running gitify package:install --all -u works great:
Newer version contentblocks-1.14.2-pl available for package contentblocks-1.14.0-rc2.
Searching modmore.com for contentblocks-1.14.2-pl...
Found 1 package(s).
Downloading ContentBlocks (1.14.2)...
Installing ContentBlocks...
Greife auf Package-Workspace zu …
Workspace-Umgebung eingerichtet, installiere jetzt das Package …
Checking minimum requirements...
MODX 2.7+ (minimum): ✔ 3.1.0-pl
PHP 7.2+ (minimum): ✔ 8.3.14
Minimum requirements look good!
Installing files from /core/packages/contentblocks-1.14.2-pl/xPDOFileVehicle/41a6e4801a85e20e29002521e8e4683d/ to /core/components/contentblocks
Attempting to preserve files at /core/components/contentblocks into archive /core/packages/contentblocks-1.14.2-pl/xPDOFileVehicle/41a6e4801a85e20e29002521e8e4683d.preserved.zip
Installing files from /core/packages/contentblocks-1.14.2-pl/xPDOFileVehicle/850af05cc9227d52d994c36ef9a91100/ to /site/assets/components/contentblocks
Attempting to preserve files at /site/assets/components/contentblocks into archive /site/core/packages/contentblocks-1.14.2-pl/xPDOFileVehicle/850af05cc9227d52d994c36ef9a91100.preserved.zip
Package decrypted!
Done!
@Finetuned is also working on upgrading packages via the CLI for the upcoming MODX CLI. Perhaps we could reuse this PR https://github.com/modmore/Gitify/pull/458?