swpm
swpm copied to clipboard
Adding additional info utilities
Hey, this PR just adds some extra info methods that I needed personally for some CI pipelines. I've separated the data fetching logic from the rendering logic to avoid repeat work.
Hope it helps!
swpm --info --json will return the info spec in JSON format
> swpm --info --json`
{
"_": "npm",
"using": "npm",
"error": null,
"ready": true,
"origin": "pinned",
"volta": true,
"versions": {
"swpm": "2.6.0",
"node": "20.9.0",
"npm": "10.2.1"
}
}
If you pass a value to info it'll pick that value back.
> swpm --info=using
npm
> swpm --info origin
pinned
> swpm --info versions.node
20.9.0
> swpm --info brokenSelection
Invalid value - brokenSelection doesn't match any available value
using: npm
origin: 📌 pinned
volta: ⚡ detected
Versions:
swpm: 2.6.0
Node: 20.9.0
npm: 10.2.1
The final brokenSelection example will run exit(1)
No value renders the same CLI output as previous.
> swpm --info
using: npm
origin: 📌 pinned
volta: ⚡ detected
Versions:
swpm: 2.6.0
Node: 20.9.0
npm: 10.2.1
Hi @joshmeads I'm actually running out of time, but I will try to take a look at it this weekend.