dyweb / Ayi

Ayi organizes your workspace
MIT License
11 stars 2 forks source link

Embed static content to binary #47

Closed at15 closed 6 years ago

at15 commented 8 years ago

Decided to use rice for embedding assets

-- old content -- This issue is split from #15. Static content is needed for both web interface and generator.

There are two choices

at15 commented 8 years ago

I think rice has a cleaner api

at15 commented 8 years ago

Test files are not build by go, thus call for FindBox in *_test.go won't be found by rice cli

go build -o Ayi
rice append -i github.com/dyweb/Ayi/util/embed --exec Ayi
no calls to rice.FindBox() or rice.MustFindBox() found in import path `github.com/dyweb/Ayi/util/embed`
Error setting zip offset: exit status 13

But how to add multiple import paths?

at15 commented 8 years ago

For the zip problem

$ zip -A Ayi
        zip warning: central dir not where expected - could not adjust offsets
        zip warning: (try -FF)

zip error: Zip file structure invalid (Ayi)
at15 commented 8 years ago

From https://github.com/GeertJohan/go.rice/issues/4

You can currently do this by using rice --import-path append --exec alpaca.exe. But that will only allow you to append/embed one package.

Doing a recursive find in all imported packages is something I thought about before.. Simply finding boxes recursively in packages probably won't work since rice allows relative paths, and so you might get multiple different folders with the same name (e.g. templates folder in different packages). It'll probably require some breaking changes in the way a package is appended/embedded and loaded during execution. Maybe need to append with full (absolute) path's to avoid duplicates. I hope the rice with --import-path will solve your problem. I'll add 'finding boxes in imported packages' to the TODO list.

but multiple packages is supported, by calling -i multiple times? and I need to rename the boxes with prefixes, like app-web-assets, app-generator-assets

at15 commented 8 years ago

I disabled zip -A and is currently using my own fork https://github.com/at15/go.rice , though it's better to detect OS, but I don't have test environment, so just make sure windows is working.

at15 commented 6 years ago

use gommon/noodle, which support .noodleignore https://github.com/dyweb/gommon/pull/47