⬆️ OutdatedPackages
Shows all outdated packages in the project along with available updates, equivalent to composer outdated.
When to use
- 🔄 Periodically check whether dependencies have new versions available to upgrade.
- 📈 Monitor technical debt in CI and output an outdated package report.
- 🔒 Assess the impact scope before upgrading.
Signature
go
func (c *Composer) OutdatedPackages() (string, error)Parameters
None.
Return value
| Value | Type | Description |
|---|---|---|
| Output | string | The text output of the outdated packages list |
| Error | error | Returned when an error occurs while fetching the outdated packages list |
Example
go
package main
import (
"fmt"
"log"
"github.com/scagogogo/composer-skills/pkg/composer"
)
func main() {
comp, err := composer.New(composer.DefaultOptions())
if err != nil {
log.Fatalf("init failed: %v", err)
}
output, err := comp.OutdatedPackages()
if err != nil {
log.Fatalf("failed to get outdated packages list: %v", err)
}
fmt.Println("Outdated packages:", output)
}Advanced
Structured results
When you need programmatic processing, use GetOutdatedInfo instead. It runs composer outdated --format=json and parses it into *OutdatedResult, containing Installed/Latest/LatestStatus for each package.
Narrowing the scope
OutdatedPackagesDirect(): only look at dependencies directly declared incomposer.json.ShowOutdatedWithFormat(format): specify the output format (e.g.json).OutdatedWithOptions(options)/OutdatedWithFormat(format): more flexible variants.
🔍 Related methods
GetOutdatedInfo: structured outdated package information.BumpPackages: upgrade packages to the latest version within their constraints.