• Stars
    star
    125
  • Rank 286,335 (Top 6 %)
  • Language
    Go
  • License
    MIT License
  • Created about 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Bundle your Astilectron app with ease

This package provides a way to bundle an astilectron app using the bootstrap.

Check out the demo to see a working example.

Installation

Run the following command:

go get -u github.com/asticode/go-astilectron-bundler/...

Build the binary

Run the following command:

go install github.com/asticode/go-astilectron-bundler/astilectron-bundler

Configuration

astilectron-bundler uses a configuration file to know what it's supposed to do.

Basic configuration

Here's the basic configuration you'll usually need:

{
  "app_name": "Test",
  "icon_path_darwin": "path/to/icon.icns",
  "icon_path_linux": "path/to/icon.png",
  "icon_path_windows": "path/to/icon.ico"
}

It will process the project located in the current directory and bundle it in the output dir for your os/arch.

Bundle for specific Astilectron and/or Electron versions

The following customization can be made to bundler.json

  • version_electron - version of electron, defaults to the value specified in the go-astilectron version you're using
  • version_astilectron - version of astilectron, defaults to the value specified in the go-astilectron version you're using

Bundle for other environments

You can bundle your project for multiple environments with the environments key:

{
  "environments": [
    {"arch": "amd64", "os": "darwin"},
    {"arch": "amd64", "os": "linux"},
    {
      "arch": "amd64",
      "os": "windows",
      "env": {
        "CC": "x86_64-w64-mingw32-gcc",
        "CXX": "x86_64-w64-mingw32-g++",
        "CGO_ENABLED": "1"
      }
    }
  ]
}

For each environment you can specify environment variables with the env key.

Adapt resources

You can execute custom actions on your resources before binding them to the binary such as uglifying the .js files with the resources_adapters key:

{
  "resources_adapters": [
    {
      "args": ["myfile.js", "mynewfile.js"],
      "name": "mv"
    },
    {
      "args": ["-flag", "value", "mynewfile.js"],
      "name": "myawesomebinary"
    }
  ]
}

All paths must be relative to the resources folder except if you provide a dir option (a path relative to the resources folder) in which case it will be relative to that path.

Build flags

You can pass arbitrary build flags into the build command with the build_flags key:

{
  "build_flags": {
    "gcflags": "\"all=-N -l\""
  }
}

Custom paths

You can set the following paths:

  • input_path: path to your project. defaults to the current directory
  • go_binary_path: path to the go binary. defaults to "go"
  • output_path: path to the dir where you'll find the bundle results. defaults to current directory/output
  • resources_path: path where the resources dir is and will be written. path must be relative to the input_path. defaults to "resources"
  • vendor_dir_path: path where the vendor dir will be written. path must be relative to the output_path
  • working_directory_path: path to the dir where the bundler runs its operations such as provisioning the vendor files or binding data to the binary

Adapt the bind configuration

You can use the bind attribute to alter the bind configuration like so:

{
  "bind": {
    "output_path": "path/to/bind/output/path",
    "package": "mypkg"
  }
}
  • output_path: path to the directory where you want bind files to be created. defaults to the current working directory
  • package: the package name to use for the bind files. defaults to "main"

When you specify an output_path, the package will probably need to be set.

Info.plist generation from the bundler configuration file property

You can add custom Info.plist configuration to the bundler.json:

{
  "app_name": "Best App",
  "icon_path_darwin": "resources/icon.icns",
  "info_plist": {
    "CFBundlePackageType": "APPL",
    "CFBundleInfoDictionaryVersion": "6.0",
    "CFBundleIconFile": "icon.icns",
    "CFBundleDisplayName": "Best App",
    "CFBundleExecutable": "app_binary",
    "CFBundleIdentifier": "com.company.BestApp",
    "LSUIElement": "NO",
    "LSMinimumSystemVersion": "10.11",
    "NSHighResolutionCapable": true,
    "NSAppTransportSecurity": {
      "NSAllowsArbitraryLoads": true
    }
  }
}

Usage

If astilectron-bundler has been installed properly (and the $GOPATH is in your $PATH), run the following command:

astilectron-bundler -c <path to your configuration file>

or if your working directory is your project directory and your bundler configuration has the proper name (bundler.json)

astilectron-bundler

Output

For each environment you specify in your configuration file, astilectron-bundler will create a folder <output_path you specified in the configuration file>/<os>-<arch> that will contain the proper files.

Ldflags

astilectron-bundler uses ldflags when building the project. It means if you add one of the following variables as global exported variables in your project, they will have the following value:

  • AppName: filled with the configuration app name
  • BuiltAt: filled with the date the build has been done at
  • VersionAstilectron: filled with the version of Astilectron being bundled/used
  • VersionElectron: filled the version of Electron being bundled/used

You can use the following to alter the Ldflags behavior:

{
  "ldflags_package": "some/path/to/pkg"
}
  • ldflags_package: which local package these variables exist in. defaults to bind's package value (for backwards compatibility)

If you need to add more flags yourself, like for a version number, add something like this to your astilectron-bundler command: -ldflags X:main.Version=xyzzy.

If you need to add multiple flags you can pass -ldflags multiple times, with multiple values split on commas, like this:

-ldflags X:main.Version=xyzzy,main.CommitCount=100 -ldflags race

That would set two variables and enable the race detection.

(in either case, make sure to substitute main with the package where your Version/CommitCount/etc. variables exist)

Commands

Only bind data: bd

Use this command if you want to skip most of the bundling process and only bind data/generate the bind.go file (useful when you want to test your app running go run *.go):

astilectron-bundler bd -c <path to your configuration file>

Clear the cache: cc

The bundler stores downloaded files in a cache to avoid downloading them over and over again. That cache may be corrupted. In that case, use this command to clear the cache:

astilectron-bundler cc

Frequent problems

"xxx architecture of input file `xxx' is incompatible with xxx output"

When building for linux you may face an error looking like this:

FATA[0009] bundling failed: bundling for environment linux/amd64 failed: building failed: # github.com/asticode/go-astilectron-demo
/usr/local/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: i386 architecture of input file `/tmp/go-link-275377070/000000.o' is incompatible with i386:x86-64 output
collect2: error: ld returned 1 exit status

Thanks to this comment, you need to add the ldflags key to your bundler.json with the value {"linkmode":["internal"]}.

More Repositories

1

go-astilectron

Build cross platform GUI apps with GO and HTML/JS/CSS (powered by Electron)
Go
4,745
star
2

go-astits

Demux and mux MPEG Transport Streams (.ts) natively in GO
Go
479
star
3

go-astisub

Manipulate subtitles in GO (.srt, .ssa/.ass, .stl, .ttml, .vtt (webvtt), teletext, etc.)
Go
463
star
4

go-astilectron-demo

Discover the power of Astilectron through a demo app
Go
397
star
5

go-astiencoder

Go
308
star
6

astilectron

Electron app that provides an API over a TCP socket that allows executing Electron's method as well as capturing Electron's events
JavaScript
274
star
7

go-astibob

Golang framework to build an AI that can understand and speak back to you, and everything else you want
Go
239
star
8

go-astideepspeech

Golang bindings for Mozilla's DeepSpeech speech-to-text library
Go
170
star
9

go-astiav

Better C bindings for ffmpeg in GO
Go
86
star
10

go-astilectron-bootstrap

Create a one-window application using Astilectron
Go
60
star
11

go-astitodo

Parse TODOs in your GO code
Go
60
star
12

go-asticoqui

Golang bindings for Coqui's speech-to-text library
Go
29
star
13

go-astikit

Set of golang helpers that don't require any external dependencies
Go
29
star
14

go-astivid

Set of video tools available through a nice UI
Go
27
star
15

go-astisrt

SRT server, client and socket in GO
Go
26
star
16

go-astitools

Set of augmented functions for the GO programming language (http://golang.org)
Go
17
star
17

go-astitello

Golang implementation of DJI Tello SDK
Go
10
star
18

go-texttospeech

Text to speech manager relying on the OS speech recognition software
Go
10
star
19

go-astiffprobe

Use your FFProbe binary to gather quality information about your video files
Go
10
star
20

go-astisplash

Cross platform splash screen
Go
9
star
21

go-astichat

A lightweight encrypted chat written in GO
Go
8
star
22

go-astilog

Golang logger
Go
8
star
23

js-toolbox

Set of components and methods to ease HTML/CSS/JS developments
JavaScript
6
star
24

go-astiws

Wrapper on top of websockets
Go
5
star
25

go-bindata

Hard fork from https://github.com/jteeuwen/go-bindata after it has disappeared
Go
5
star
26

go-stopwatch

Deprecated
Go
5
star
27

go-astitesseract

Wrapper for the Tesseract OCR project
Go
5
star
28

go-asticrypt

Send encrypted messages through your favourite apps
Go
4
star
29

go-astiffmpeg

Use your FFMpeg binary to manipulate your video files
Go
4
star
30

go-astiocr

Go
4
star
31

go-keyboardemulator

Cross-OS keyboard emulator that can take control of your keyboard through code
Go
4
star
32

go-slack

TODO: clone and rename
Go
2
star
33

go-astimysql

Wrapper on top of mysql to provide proper configuration
Go
2
star
34

go-astiratp

Clients for the RATP APIs
Go
2
star
35

go-astiamqp

Wrapper on top of amqp to provide proper configuration and error handling
Go
2
star
36

go-bob

Bob is an AI capable of taking over your keyboard based on voice commands
Go
2
star
37

go-astiproxy

Wrapper on top of http and url to provide proper proxy configuration
Go
2
star
38

go-astichartjs

Go
2
star
39

asticrypt

Encrypt your conversations and stop being tracked when using your favorite apps
JavaScript
2
star
40

php-deployment-manager

Deployment manager to enable automatic deployment of PHP or GO projects on your server after a GIT push
PHP
2
star
41

go-astislack

Clear your Slack history easily
Go
1
star
42

go-astimgo

Wrapper on top of mgo to provide proper configuration
Go
1
star
43

go-ftp

TODO: clone and rename
Go
1
star
44

go-speechtotext

Speech to text manager relying on the OS speech recognition software
1
star
45

go-astiredis

Wrapper on top of redis to provide proper configuration
Go
1
star
46

go-test

Sandbox for GO
Go
1
star
47

go-astiudp

Go
1
star
48

go-astilectron-deployer

Go
1
star
49

go-astitwitter

Wrapper on top of Twitter API
Go
1
star
50

go-astibank

Simple tool to monitor your bank accounts
Go
1
star
51

test

1
star
52

php-cache-manager

Cache manager for PHP
PHP
1
star
53

go-gozzle

Deprecated
Go
1
star
54

go-astibike

Should I travel by bike this week?
Go
1
star
55

go-pprof

TODO: merge stopwatch + add ticker
Go
1
star
56

go-astipatch

Patch manager written in GO
Go
1
star
57

go-astibob-demos

Official astibob demos
Go
1
star
58

php-data-mapper

Mapper and Repository factories that implements the Data Mapper structure
PHP
1
star
59

python-asticredits

1
star
60

js-astiyoga

JavaScript
1
star
61

php-file-manager

File manager to handle cross-datasources copy as well as simple file actions on the most common datasources
PHP
1
star