facebook / dotslash

Simplified executable deployment
https://dotslash-cli.com
Apache License 2.0
535 stars 14 forks source link

Support .zip archives #13

Closed abhinav closed 3 months ago

abhinav commented 4 months ago

Similarly to #12, this adds support for .zip archives. Examples of projects using zip only:

The code differentiates between the decompression step (e.g. xz gzip, etc.) and the archive format (e.g. tar, zip). So unlike .tar.gz, this adds a new ArchiveFormat.

In match arms, this adds the possibility of attempting to handle .zip.gz or similar, but that's not allowed at the entry point, so the code errors or panics if it encounters that.

To keep the file size down, the default features of the zip crate were disabled. Namely, support for encrypted archives and bzip2 was left out. Based on my read of this summary of history of archive formats, this configuration should be sufficient for a vast majority of zip files.

There's also a 'time' feature flag that enables integration with the time crate that was also left out.

File size impact:

❯ git checkout main
❯ cargo build --release
❯ wc -c target/release/dotslash
  985208 target/release/dotslash

❯ git checkout zip
❯ cargo build --release
❯ wc -c target/release/dotslash
 1018312 target/release/dotslash

Currently, this change adds 33,104 bytes to the binary size on macOS. Enabling the (currently disabled) bzip2 feature flag would add another 33,232 bytes. Disabling the (currently enabled) zstd flag does not reduce the file size.

License: zip-rs is licensed under MIT, so it's safe to use here.

Testing: Besides accompanying unit tests, tested manually with the following file per #8:


{
  "name": "dprint",
  "platforms": {
    "macos-aarch64": {
      "size": 7030235,
      "hash": "blake3",
      "digest": "a16c60d1692ad21e12f9d7b167b3dc9d4e5f34c2c1afd5e705842f5ab3e94e0e",
      "format": "zip",
      "path": "dprint",
      "providers": [
        {
          "url": "https://github.com/dprint/dprint/releases/download/0.45.0/dprint-aarch64-apple-darwin.zip"
        }
      ]
    }
  }
}

Resolves #8

zertosh commented 4 months ago

Give me a few days to come up with test fixtures. I need to add some of .zip and .xz. Given my past poor experience with this crate, I'd feel more comfortable confirming that the test archives work

abhinav commented 4 months ago

Sounds good! Thanks for dropping that note, @zertosh.

hn8 commented 4 months ago
https://github.com/facebook/dotslash/releases/tag/v0.2.0 filename size
dotslash-macos.v0.2.0.tar.gz 1.01 MB
dotslash-ubuntu.v0.2.0.tar.gz 602 KB
dotslash-windows.v0.2.0.tar.gz 438 KB
with both xz and zip support from @abhinav, and compress by gzip --best (excluding windows), the new release sizes: https://github.com/datamana-app/dotslash/releases/latest filename size
dotslash-darwin-aarch64.tar.gz 538 KB
dotslash-darwin-x86_64.tar.gz 616 KB
dotslash-darwin.tar.gz 1.13 MB
dotslash-linux-aarch64.tar.gz 595 KB
dotslash-linux-x86_64.tar.gz 659 KB
dotslash-windows-x86_64.tar.gz 501 KB
paulhammond commented 4 months ago

Just wanted to confirm that this branch also works with deno. It would be great to see it merged into main...

zertosh commented 4 months ago

So sorry, I'll give this some time tmw

facebook-github-bot commented 4 months ago

@zertosh has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator.

CheRuisiBesares-IBM commented 3 months ago

Hi. Im interested in trying to adopt this tool for some of our projects. Unfortunately we rely on several things distributed via zip only. Is there any contribution/help that I can provide to get this landed in the main branch?

facebook-github-bot commented 3 months ago

@zertosh merged this pull request in facebook/dotslash@fb65e2886a1ca05e3b558f0fc396e26bed1908c4.

zertosh commented 3 months ago

Sorry this took so long! I had to use an outdated version of the zip crate because that's what we have internally. I'm in the process of updating that