asticode / go-astilectron-bundler

Bundle your Astilectron app with ease

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Question] Download astilectron and electron separately from astilectron-bundler?

olof-nord opened this issue · comments

Hello @asticode, I got a tricky situation which I am looking into.

I want to bundle an application in an environment which cannot download any artifacts at runtime, but they need to be specified and downloaded separately. (Flathub packaging: all dependencies must be declared and downloaded before execution as per their rules)

Looking at the excellent logging during the astilectron-bundler execution, I understand the following:

  1. The two archives are downloaded:
  • /tmp/astibundler/cache/astilectron-0.51.0.zip
  • /tmp/astibundler/cache/electron-linux-amd64-16.0.8.zip
  1. The two archives are copied here:
  • /tmp/astibundler/bind/vendor_astilectron_bundler/astilectron.zip
  • /tmp/astibundler/bind/vendor_astilectron_bundler/electron.zip
  1. After this, the HTML/JS/CSS resources are put in place, and the golang code is built etc.

Is there any way to tell the bundler to skip 1) and 2) of the above, and just take two archives which are downloaded in beforehand? If so, is it expected that the archives are in /tmp/astibundler/cache or in /tmp/astibundler/bind (or someplace else?)

I have found the astilectron.Options.SkipSetup setting, which seems to be used for something similar to this, but parallel to me trying out things I thought I would ask you directly as well as to hear your opinion on this.

If I would name this (hypothetical) option something, I think of it more as SkipDownload as SkipSetup: I understand this functionality as somewhat existing as the two archives are only downloaded once on the first run, and later re-used, right?

Any opinion and feedback on the matter would be greatly appreciated!

What you could try doing is:

  1. Create a temporary working directory (for the sake of the example, let's call it /tmp/dir)
  2. Create a cache folder inside it
  3. Download both astilectron and electron zip files using whatever tool you want to use in this folder. Beware as you need to get the correct versions for your OS and Arch. Full correct urls are available with exported functions astilectron.AstilectronDownloadSrc() and astilectron.ElectronDownloadSrc()
  4. In your bundler.json, use the working_directory_path attribute to specify the path to you working directory.

That way, the bundler will see both zip files are already in the cache folder and won't download anything.

If you feel like contributing to this project, a better option would be to add a cache_path attribute the bundler configuration and use this value if not empty instead of the default value. That way you would only need to create a custom cache folder and if one day the bundler has a different default folder structure, there won't be any risk of your first solution not working anymore.

amazing!

With your advice, downloading the artifacts separately works like a charm.

Regarding the config: Of course a specific cache_path would be a great addition, but as the working_directory_path already is configurable, at least for this scenario, all is fine.

If you are interested, here is the full Flatpak Manifest:
https://gitlab.com/olof-nord/go-astilectron-flatpak-offline-demo/-/blob/main/go-astielectron-flatpak-offline-demo.yml