astibundler

package module
v0.0.0-...-1ac1616 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 5, 2017 License: MIT Imports: 18 Imported by: 1

README

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/...

Configuration

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

{
  "app_name": "Test",
  "environments": [
    {"arch": "amd64", "os": "darwin"},
    {"arch": "amd64", "os": "linux"},
    {"arch": "amd64", "os": "windows"}
  ],
  "icon_path_darwin": "path/to/icon.icns",
  "icon_path_linux": "path/to/icon.png",
  "icon_path_windows": "path/to/icon.ico",
  "input_path": "path/to/src/github.com/username/project",
  "output_path": "path/to/output/directory"
}

Paths can be either relative or absolute but we strongly encourage to use relative paths.

If no input path is specified, the working directory path is used.

We strongly encourage to leave the input path option empty and execute the bundler while in the directory of the project you're bundling.

Usage

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

$ astilectron-bundler -v -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 -v

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

Subcommands

Only bind data: bd

Use this subcommand 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 -v -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 subcommand to clear the cache:

$ astilectron-bundler cc -v

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewProvisioner

func NewProvisioner(disembedFunc func(string) ([]byte, error)) astilectron.Provisioner

NewProvisioner builds the proper disembedder provisioner

Types

type Bundler

type Bundler struct {
	Client *http.Client
	// contains filtered or unexported fields
}

Bundler represents an object capable of bundling an Astilectron app

func New

func New(c *Configuration) (b *Bundler, err error)

New builds a new bundler based on a configuration

func (*Bundler) BindData

func (b *Bundler) BindData(os, arch string) (err error)

BindData binds the data

func (*Bundler) Bundle

func (b *Bundler) Bundle() (err error)

Bundle bundles an astilectron app based on a configuration

func (*Bundler) ClearCache

func (b *Bundler) ClearCache() (err error)

ClearCache clears the bundler cache

func (*Bundler) HandleSignals

func (b *Bundler) HandleSignals()

HandleSignals handles signals

func (*Bundler) Stop

func (b *Bundler) Stop()

Stop stops the bundler

type Configuration

type Configuration struct {
	// The app name as it should be displayed everywhere
	// It's also set as an ldflag and therefore accessible in a global var main.AppName
	AppName string `json:"app_name"`

	// The bundler cache the vendor content in this path.
	// Best is to leave it empty.
	CachePath string `json:"cache_path"`

	// List of environments the bundling should be done upon.
	// An environment is a combination of OS and ARCH
	Environments []ConfigurationEnvironment `json:"environments"`

	// Paths to icons
	IconPathDarwin  string `json:"icon_path_darwin"` // .icns
	IconPathLinux   string `json:"icon_path_linux"`
	IconPathWindows string `json:"icon_path_windows"` // .ico

	// The path of the project.
	// Best is to leave it empty and execute the bundler while in the project folder
	InputPath string `json:"input_path"`

	// The path of the go binary
	// Best is to leave it empty. Default value is "go"
	GoBinaryPath string `json:"go_binary_path"`

	// The path where the files will be written
	OutputPath string `json:"output_path"`

	//!\\ DEBUG ONLY
	AstilectronPath string `json:"astilectron_path"` // when making changes to astilectron
}

Configuration represents the bundle configuration

type ConfigurationEnvironment

type ConfigurationEnvironment struct {
	Arch string `json:"arch"`
	OS   string `json:"os"`
}

ConfigurationEnvironment represents the bundle configuration environment

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL