cake icon indicating copy to clipboard operation
cake copied to clipboard

Feature request: built-in scheme for #tool to download an arbitrary HTTPS .zip file

Open jnm2 opened this issue 4 years ago • 3 comments

Parameters

  • Version parameter: no. There would be no notion of the downloaded tool having a version, so no version or prerelease parameters.

  • Format parameter: maybe The format could be autodetected from the content type or file contents in case you eventually support archive formats other than .zip. There probably wouldn't be a need for a type/format parameter but it might be desirable.

  • Checksum parameter: I want this. Even if the download is over HTTPS, it's nice to know if something else starts getting served. This would make HTTP/FTP URLs safe too. If the checksum is missing, Cake could download the file and then include the checksum in an error message requiring the checksum to be present in the .cake file.

Since query parameters in the same URL would collide with the URL to use for the download whether or not they are excluded when downloading, there would need to be a new way to handle this.

Proposal

#tool download: followed by a URL. If the URL contains a comma, it must be URL-encoded.

A parameter may be specified no more than once. Some parameters are required. To specify a parameter, add a comma to the end of the line followed by the parameter name, an equals sign, and a parameter value. If the parameter value contains a double quote character or comma, the whole parameter value must be double-quoted.

Valid parameter names:

  • checksum: Required. Value must start with SHA256: and the remainder must be 32 hex characters, case-insensitive. Future checksums may be supported.
#tool download:http://static.wixtoolset.org/releases/v3.14.0.3910/wix314-binaries.zip, checksum=SHA256:0904A88A4BCD9DD3C2274CAABE73989CD72767EE90C8FA0BF813D004EEC90D32

Questions

  1. Is a format parameter desirable even if multiple formats become supported?

  2. Should there be support for the file scheme or absolute or relative or Windows UNC paths?

  3. Should checksum be allowed to be omitted for HTTPS downloads? What about HTTP/FTP/file schemes?

jnm2 avatar Mar 12 '20 17:03 jnm2

I think this initially best would be implemented and tested as Cake module. Example of Cake modules: https://github.com/cake-contrib/Cake.DotNetTool.Module

https://github.com/cake-contrib/Cake.Chocolatey.Module

Documentation around modules here https://cakebuild.net/docs/fundamentals/modules

devlead avatar Mar 12 '20 18:03 devlead

@devlead Sounds good. I'm probably not up for it at this time, but maybe this proposal could interest someone else. Would you prefer this issue to be closed or stay open?

(I would be happy to help build a lexer and parser if needed though—those are fun.)

jnm2 avatar Mar 12 '20 18:03 jnm2

@jnm2 there is another module that could be used as a reference is this one:

https://www.nuget.org/packages/Cake.UrlLoadDirective.Module/

Which does something similar.

gep13 avatar Mar 13 '20 17:03 gep13