mumoshu / variant2

Turn your bash scripts into a modern, single-executable CLI app today
MIT License
141 stars 11 forks source link

Feature Request: variant export binary should bundle modules #28

Closed osterman closed 3 years ago

osterman commented 3 years ago

what

why

mumoshu commented 3 years ago

@osterman Hey! I'm now working on this.

Firstly I tried to implement this by producing a “flattened” version of all the local and remote variant sources. The flattened sources can be embedded into the binary then.

It requires the modified (flattened) .variant file to the disk using some hcl2 functionality. But the functionality, hclwrite, seems very limited and unable to encode HCL2 construtcts used in Variant. So I’m going to abandon this idea.

https://github.com/mumoshu/variant2/commit/01c55e4708905c38e8d6f13758098e5519fa4f67

mumoshu commented 3 years ago

I'll try embedding the module files using statik (or packr, packr2, pkger, or whatever?) next.

Internally Variant2 will be changed to use an overlay filesystem composed of statik fs and the real os filesystem, and prefer reading from the former so that embedded files are read if exists and the os files are tried next(variant run and shim cases).

This seems a bit inelegant, but should work universally. And It's possible without interfering with complex hcl2 functionalities.