I'm opening this topic trying to understand the limitations we have in place for computing the checksum of an arbitrary package and if it would be justified to support this operation without requiring the caller to be in any package root.
swift package compute-checksum /absolute/path/to/some/package.zip fails with
error: Could not find Package.swift in this directory or any of its parent directories. if called from outside a package.
When writing scripts and generally automating releases you want to output the correct checksum without being forced to be inside a package directory or artificially create one just for this purpose.
- Is there a reason I'm missing for which we enforce this behaviour on the user?
- What's the limitation here?
- Would the effort put in changing this justify the relatively small gain? (I really dislike having to create fake
Package.swifts, but I can understand it's niche use case)
The checksum is SHA256, so you can do
shasum -a 256 foo.zip | cut -b 1-64 rather than use compute-checksum.
I know, but that kinda beats the purpose of
compute-checksum (you're assuming you know the hashing algo now and forever). Won't argue, might work now and forever just as well, but I'd rather use
compute-checksum as intended.
swift package and all its subcommands require a package currently.
I don't think it is trivial to do something specific for
compute-checksum but we have previously talked about reorganizing SwiftPM's command structure so that
swift package itself doesn't carry semantics like that which would allow us to reparent things like
package-collection as well. When that happens, I would imagine that
compute-checksum would no longer require a package.
Alright @NeoNacho, so it's safe to assume this is on the radar and it would be non-trivial trying to push it as a small improvement before the more general command structure reshaping. Do you know if there's a plan for this restructuring, or just general talks? Slightly unrelated, but I'm curious to follow.
There's no concrete plan so far, but it has come up multiple times.