📦 OutdatedPackagesDirect Show only outdated direct dependencies
🔍
OutdatedPackagesDirectshows only outdated packages among the dependencies directly declared incomposer.json, excluding transitive dependencies. It is equivalent to runningcomposer outdated --direct, suitable for quickly identifying your own dependencies that need updating.
📋 Signature
go
func (c *Composer) OutdatedPackagesDirect() (string, error)📥 Parameters
| Parameter | Type | Description |
|---|---|---|
| None | — | This method takes no parameters |
📤 Return value
| Return value | Type | Description |
|---|---|---|
| First return value | string | The text output of the outdated direct dependencies list |
| Second return value | error | Returned when an error occurs during retrieval; nil on success |
📝 Example
go
package main
import (
"fmt"
"log"
"github.com/scagogogo/composer-skills/pkg/composer"
)
func main() {
comp, err := composer.NewComposer()
if err != nil {
log.Fatalf("failed to create Composer instance: %v", err)
}
output, err := comp.OutdatedPackagesDirect()
if err != nil {
log.Fatalf("failed to get outdated direct dependencies: %v", err)
}
fmt.Println("Outdated direct dependencies:")
fmt.Println(output)
}🚀 Advanced
- 📋 To view all outdated packages including transitive dependencies, use
OutdatedPackages(). - 🧪 To output in
jsonformat for programmatic parsing, useShowOutdatedWithFormat("json")orOutdatedWithFormat(format). - ⚙️ For custom combined options (e.g.
--direct+--minor-only), useOutdatedWithOptions(options map[string]string)with{"direct": "", "minor-only": ""}. - 🔗 In a dependency update pipeline, first use this method to filter the direct dependency update list, then use
Update([]string{...}, false)to update precisely.