[FEATURE REQUEST] remove need to copy package files to staging location
Is your feature request related to a problem? Please describe.
Is it possible to remove the need to copy the files to be put in the tarball into a staging area on the file system?
What is the reason for doing it?
This is done in the following code:
https://github.com/fastly/cli/blob/main/pkg/commands/compute/pack.go
which uses github.com/mholt/archiver/v3
Describe the solution you'd like
Ability to pack a file without copying files to a staging location.
Describe alternatives you've considered
I've created some simple alternative packing code using archive/tar from the std lib here:
https://github.com/grokify/mogo/blob/master/archive/tarutil/writer.go
which I've packed into a CLI command here:
https://github.com/grokify/fastlywasmly
But it would be great for the Fastly CLI to not create staging files itself.
Additional context
none.
Hi @grokify
I think the fastly compute pack command can now be removed.
Since the pack command was introduced we have added support for custom build scripts to the CLI. This means a user can specify a custom [scripts.build] in their fastly.toml file and the CLI will use that to compile their project.
This means fastly compute build will work with any unofficial language a user cares to use.
NOTE: Additionally, very soon (see PR) the CLI will use the
[scripts.build]field directly for building a project rather than the build logic being hardcoded into the CLI binary.
OK, I actually just stumbled into why we do this, and it's because of the dependency we use for creating the archive.
Essentially the package recursively copies all files from the specified directory, which would make the tar.gz very large. So the authors of the original code decided it was best to copy only the files necessary into a temporary directory first, and then provide the archive function with the temp directory to reduce the overall size of the package.