Documentation
¶
Overview ¶
Example (CreateAppBundle) ¶
This example demonstrates how to create a basic macOS application bundle structure with Info.plist and copy resources into it.
// Create a temporary directory for the example
tempDir, err := os.MkdirTemp("", "example_app_bundle_*")
if err != nil {
log.Fatalf("Failed to create temp dir: %v", err)
}
defer os.RemoveAll(tempDir) //nolint:errcheck
// Create a test executable (just a placeholder file for the example)
exeContent := []byte("#!/bin/bash\necho 'Hello from Example App'")
exePath := filepath.Join(tempDir, "ExampleExecutable")
if err := os.WriteFile(exePath, exeContent, 0755); err != nil { //nolint:gosec // G306
fmt.Printf("Failed to create example executable: %v", err)
return
}
plistYAML := `
CFBundleIdentifier: io.cloudeng.TestApp
CFBundleName: TestApp
CFBundleVersion: 1.0.0
CFBundleShortVersionString: 1.0
CFBundleExecutable: TestExecutable
CFBundlePackageType: APPL
LSMinimumSystemVersion: "15.0"
CFBundleDisplayName: Swift UI Example
`
var info buildtools.InfoPlist
if err := yaml.Unmarshal([]byte(plistYAML), &info); err != nil {
fmt.Printf("failed to unmarshal info plist: %v", err)
return
}
// Define the app bundle with required Info.plist contents
bundle := buildtools.AppBundle{
Path: filepath.Join(tempDir, "ExampleApp.app"),
Info: info,
}
ctx := context.Background()
runner := buildtools.NewRunner()
// Get the steps to create the basic bundle structure
runner.AddSteps(bundle.Create()...)
runner.AddSteps(bundle.WriteInfoPlist())
runner.AddSteps(bundle.CopyContents(exePath, "MacOS", "ExampleExecutable"))
results := runner.Run(ctx, buildtools.NewCommandRunner())
if err := results.Error(); err != nil {
fmt.Printf("Failed to create app bundle: %v\n", err)
}
for _, result := range results {
fmt.Printf("Step executed: %v %v\n", result.Executable(), result.Error() == nil)
}
Output: Step executed: mkdir true Step executed: mkdir true Step executed: mkdir true Step executed: write Info.plist true Step executed: cp true
Index ¶
- Constants
- func CWDFromContext(ctx context.Context) string
- func ContextWithCWD(ctx context.Context, cwd string) context.Context
- func RegisterFlagsOrDie(f any, fs *flag.FlagSet)
- type AppBundle
- func (b AppBundle) Clean() Step
- func (b AppBundle) Contents(elem ...string) string
- func (b AppBundle) CopyContents(src string, dst ...string) Step
- func (b AppBundle) CopyExecutable(src string) Step
- func (b AppBundle) CopyIcons(icons []IconSet) []Step
- func (b AppBundle) Create() []Step
- func (b AppBundle) ExecutablePath() string
- func (b AppBundle) InstallProvisioningProfile(profile string) Step
- func (b AppBundle) Resources(elem ...string) string
- func (b AppBundle) SPCtlAsses() Step
- func (b AppBundle) Sign(signer Signer) Step
- func (b AppBundle) SignContents(signer Signer, dst ...string) Step
- func (b AppBundle) SignExecutable(signer Signer) Step
- func (b AppBundle) VerifyContents(signer Signer, dst ...string) Step
- func (b AppBundle) VerifySignatures(signer Signer) []Step
- func (b AppBundle) WriteInfoPlist() Step
- func (b AppBundle) WriteInfoPlistGitBuild(_ context.Context, git Git) []Step
- type BashScript
- type Browser
- type BrowserType
- type CommandRunner
- type CommandRunnerOption
- type CommonFlags
- func (f CommonFlags) CommandRunnerOptions() []CommandRunnerOption
- func (f CommonFlags) ParseFile(cfg any) error
- func (f CommonFlags) PrintResult(spec any, result RunResult) error
- func (f CommonFlags) PrintResultAndExitOnErrorf(spec any, result RunResult)
- func (f CommonFlags) StepRunnerOptions() []StepRunnerOption
- type Config
- type Entitlements
- type File
- type Git
- type IconSet
- type IconSetDir
- type IconSizeMultiple
- type InfoPlist
- type NativeMessagingConfig
- type PerFileEntitlements
- type PkgBuild
- func (p PkgBuild) Build(outputPath string) Step
- func (p PkgBuild) Clean() Step
- func (p PkgBuild) CopyApplication(src string) Step
- func (p PkgBuild) CopyLibrary(src, library string) Step
- func (p PkgBuild) CopyScripts(src string) Step
- func (p PkgBuild) Create() []Step
- func (p PkgBuild) CreateLibrary(library string) Step
- func (p PkgBuild) Install(outputPath string) Step
- func (p PkgBuild) LibraryPath(library string) string
- func (p PkgBuild) OutputsPath() string
- func (p PkgBuild) ScriptsPath() string
- func (p PkgBuild) WritePlist(cfg []PkgComponentPlist) Step
- func (p PkgBuild) WriteScript(data []byte, name string) Step
- type PkgComponentPlist
- type ProductBuild
- type ProductBuildResources
- type ProductPreInstallRequirements
- type ReformatIcon
- type Resources
- type RunResult
- type Signer
- type SigningConfig
- type Step
- func Copy(oldname, newname string) Step
- func CopyDir(srcDir, dstDir string) Step
- func DirExists(d string) Step
- func ErrorStep(err error, cmd string, args ...string) Step
- func FileExists(f string) Step
- func IsValidIconSetDir(id IconSetDir) Step
- func MkdirAll(d string) Step
- func NoopStep(detail string) Step
- func RSync(src, dst string, args ...string) Step
- func Rename(oldname, newname string) Step
- func RmdirAll(d string) Step
- func StepFunc(f func(context.Context, *CommandRunner) (StepResult, error)) Step
- func WriteFile(data []byte, perm os.FileMode, elems ...string) Step
- func WriteJSONFile(v any, elems ...string) Step
- func WritePlistFile(v any, elems ...string) Step
- type StepResult
- type StepRunner
- type StepRunnerOption
- type Suffix
- type SwiftApp
- type XPCServicePlist
Examples ¶
Constants ¶
const BashInstallPreamble = `` /* 162-byte string literal not displayed */
BashInstallPreamble is the standard preamble for install scripts used in pkgbuild packages.
Variables ¶
This section is empty.
Functions ¶
func CWDFromContext ¶
CWDFromContext retrieves the current working directory from the context, as set by ContextWithCWD. If no directory has been set in the context the function returns the process's current working directory at the time that this package was initialized. Note that this may differ from the actual current working directory of the process if it has changed since the package was initialized or if another package that was initialized earlier has changed the current working directory of the process.
func ContextWithCWD ¶
ContextWithCWD returns a new context with the specified current working directory. CommandRunner will use this directory for executing commands.
func RegisterFlagsOrDie ¶
RegisterFlagsOrDie registers a struct that contains an instance of CommonFlags with the provided FlagSet, panicing on error.
Types ¶
type AppBundle ¶
AppBundle represents a macOS application bundle. See: https://developer.apple.com/documentation/bundleresources See: https://developer.apple.com/documentation/bundleresources/placing-content-in-a-bundle
func (AppBundle) Clean ¶
Clean returns a Step that removes the app bundle directory and all its contents.
func (AppBundle) Contents ¶
Contents returns the path to the specified element within the app bundle's Contents directory.
func (AppBundle) CopyContents ¶
CopyContents returns the step required to copy a file into the app bundle dst is relative to the bundle Contents root.
func (AppBundle) CopyExecutable ¶
CopyExecutable returns the step required to copy the executable referenced in the Info.plist into the app bundle.
func (AppBundle) CopyIcons ¶
CopyIcons returns steps to copy the specified icons into the app bundle's Resources directory. If multiple icons are specified and the icon's BundleIcon field is set or if there is only a single icon then it is copied to the location specified by the bundle's Info.plist CFBundleIconFile field. All other icons are copied to their own directories within the Resources directory.
func (AppBundle) Create ¶
Create returns the steps required to create the app bundle directory structure and Info.plist.
func (AppBundle) ExecutablePath ¶
ExecutablePath returns the absolute path to the executable inside the app bundle that is referenced in the Info.plist.
func (AppBundle) InstallProvisioningProfile ¶
InstallProvisioningProfile returns a Step that copies the provisioning profile into the app bundle. See https://developer.apple.com/documentation/technotes/tn3125-inside-code-signing-provisioning-profiles for an explanation of provisioning profiles.
func (AppBundle) Resources ¶
Resources returns the path to the specified element within the app bundle's Resources directory.
func (AppBundle) SPCtlAsses ¶
func (AppBundle) SignContents ¶
SignContents returns the step required to sign a file within the app bundle, dst is relative to the bundle Contents root.
func (AppBundle) SignExecutable ¶
SignExecutable returns the step required to sign the executable within the app bundle.
func (AppBundle) VerifyContents ¶
VerifyContents returns the step required to sign a file within the app bundle, dst is relative to the bundle Contents root.
func (AppBundle) VerifySignatures ¶
func (AppBundle) WriteInfoPlist ¶
WriteInfoPlist returns the step required to write the Info.plist file for the app bundle.
type BashScript ¶
type BashScript struct {
// contains filtered or unexported fields
}
BashScript helps in the construction of bash scripts for any pre and post install operations.
func NewBashScript ¶
func NewBashScript(preamble string) *BashScript
NewBashScript creates a new BashScript instance with the specified preamble.
func (*BashScript) Append ¶
func (b *BashScript) Append(text string)
Append appends the specified text to the script.
func (*BashScript) Bytes ¶
func (b *BashScript) Bytes() []byte
Bytes returns the script as a byte slice.
func (*BashScript) CreateInstallManifest ¶
func (b *BashScript) CreateInstallManifest(systemWide bool, manifest File)
CreateInstallManifest appends the commands to create the install manifest to the script. If the manifest's source path is empty /dev/null is used instead.
func (*BashScript) InstallFile ¶
func (b *BashScript) InstallFile(systemWide bool, file File, manifest string)
InstallFile appends the commands to install the specified file to the script. If systemWide is true the file is installed to the system location otherwise it is installed to the local user location. The manifest file, if specified, is updated with the installed file's path.
type Browser ¶
type Browser struct{}
Browser represents a web browser.
func (Browser) CreateChromeExtensionID ¶
CreateChromeExtensionID generates a stable Chrome Extension ID suitable for development use. Note that this ID is derived from a newly generated RSA key pair each time the function is called, so it will be different on each invocation. For a stable ID, you would need to persist the generated key pair.
type BrowserType ¶
type BrowserType int
const ( Chrome BrowserType = iota Firefox Safari Edge )
func (BrowserType) String ¶
func (b BrowserType) String() string
type CommandRunner ¶
type CommandRunner struct {
// contains filtered or unexported fields
}
CommandRunner executes system commands.
func NewCommandRunner ¶
func NewCommandRunner(opts ...CommandRunnerOption) *CommandRunner
NewCommandRunner creates a new CommandRunner with the provided options.
func (*CommandRunner) DryRun ¶
func (r *CommandRunner) DryRun() bool
func (*CommandRunner) Run ¶
func (r *CommandRunner) Run(ctx context.Context, name string, args ...string) (StepResult, error)
Run executes the specified command with arguments and returns the combined output and any error encountered.
type CommandRunnerOption ¶
type CommandRunnerOption func(o *commandRunnerOptions)
CommandRunnerOption configures a CommandRunner.
func WithCommandTiming ¶
func WithCommandTiming(timing bool) CommandRunnerOption
func WithDryRun ¶
func WithDryRun(dryRun bool) CommandRunnerOption
WithDryRun configures the CommandRunner to simulate command execution without actually running commands.
func WithStderr ¶
func WithStderr(w io.Writer) CommandRunnerOption
WithStderr configures the CommandRunner to write standard error to the provided io.Writer.
func WithStdout ¶
func WithStdout(w io.Writer) CommandRunnerOption
WithStdout configures the CommandRunner to write standard output to the provided io.Writer.
type CommonFlags ¶
type CommonFlags struct {
DryRun bool `subcmd:"dry-run,false,'if set, execute the commands in dry-run mode'"`
Timing bool `subcmd:"timing,false,'if set, print timing information for each step'"`
Release bool `subcmd:"swift-release,false,'if set, use swift release build, otherwise debug'"`
BundlePath string `subcmd:"bundle-path,'','path for the output bundle, overrides any specified in a config file'"`
Signer string `subcmd:"signer,'','signing identity to use, overrides any specified in a config file'"`
ConfigFile string `subcmd:"config,'spec.yaml','path to the build specification yaml file'"`
Verbose bool `subcmd:"verbose,false,'if set, print verbose output'"`
}
CommonFlags represents flags commonly used by buildtools command line tools.
func (CommonFlags) CommandRunnerOptions ¶
func (f CommonFlags) CommandRunnerOptions() []CommandRunnerOption
CommandRunnerOptions returns options for the CommandRunner based on the flags.
func (CommonFlags) ParseFile ¶
func (f CommonFlags) ParseFile(cfg any) error
ParseFile parses the specified config file into cfg.
func (CommonFlags) PrintResult ¶
func (f CommonFlags) PrintResult(spec any, result RunResult) error
func (CommonFlags) PrintResultAndExitOnErrorf ¶
func (f CommonFlags) PrintResultAndExitOnErrorf(spec any, result RunResult)
PrintResultAndExitOnErrorf prints the results of running steps and exits with a non-zero status if any of the steps failed.
func (CommonFlags) StepRunnerOptions ¶
func (f CommonFlags) StepRunnerOptions() []StepRunnerOption
StepRunnerOptions returns options for the StepRunner based on the flags.
type Config ¶
type Config struct {
AppBundle string `yaml:"bundle"`
Signing SigningConfig `yaml:"signing"`
}
Config represents common configuration options that can be read from a yaml config file.
type Entitlements ¶
type Entitlements struct {
// contains filtered or unexported fields
}
Entitlements represents a set of macOS app entitlements that are specified as YAML.
func (Entitlements) MarshalIndent ¶
func (e Entitlements) MarshalIndent(indent string) ([]byte, error)
MarshalIndent returns the XML plist representation of the entitlements with the specified indent.
func (Entitlements) MarshalPlist ¶
func (e Entitlements) MarshalPlist() (any, error)
func (Entitlements) MarshalYAML ¶
func (e Entitlements) MarshalYAML() (any, error)
func (*Entitlements) UnmarshalYAML ¶
func (e *Entitlements) UnmarshalYAML(node *yaml.Node) error
type File ¶
type File struct {
Src string `yaml:"src"`
DstLocal string `yaml:"local"`
DstSystem string `yaml:"system"`
}
func (File) OneOf ¶
OneOf returns the destination path to use for the file. If both DstLocal and DstSystem are set an empty string is returned, if neither is set the source path is returned, otherwise one of the system or local destination paths is returned.
func (File) RewriteHOME ¶
RewriteHOME rewrites any occurrences of $HOME in the source and destination paths to ${TARGET_HOME} which is set in the bash script preamble. Use this with the BashInstallPreamble to access the current logged in user's home directory since $HOME does not refer to the user's home directory from within the installer environment.
type Git ¶
type Git struct {
// contains filtered or unexported fields
}
func NewGit ¶
NewGit creates a new Git instance rooted at the specified directory which must be within a git repository.
func (Git) Hash ¶
func (g Git) Hash(ctx context.Context, cmdRunner *CommandRunner, branch string, n int) (StepResult, error)
func (Git) ReplaceBranch ¶
type IconSet ¶
type IconSet struct {
Icon string `yaml:"icon"`
Dir string `yaml:"dir"`
Name string `yaml:"name"` // defaults to AppIcon.icns
Sizes []int `yaml:"sizes,flow"` // optional - defaults to standard sizes if not provided
Multiple IconSizeMultiple `yaml:"multiple"` // optional - defaults to 3 (1x, 2x and 3x) if not provided
Format string `yaml:"format"` // optional - defaults to png if not provided
// if true, the icon is copied to the bundle Resources directory
// as the file specified by CFBundleIconFile in the Info.plist
BundleIcon bool `yaml:"bundle_icon"`
}
IconSet represents a directory that contains the variously sized icons needed to create an .icns file from a single source icon.
func (IconSet) CreateIcns ¶
func (IconSet) CreateIconVariants ¶
CreateIconVariants creates the variously sized icons needed for the icon set. If no sizes are provided, a default set is used. The highest_multiple parameter indicates the highest scale factor to use, e.g., 2 for 1x and 2x, 3 for 1x, 2x and 3x.
func (IconSet) IconFormat ¶
func (IconSet) IconSetDir ¶
func (IconSet) IconSetFile ¶
func (IconSet) IconSetName ¶
type IconSizeMultiple ¶
type IconSizeMultiple int
IconSizeMultiple represents the scale factor for icon sizes, e.g., 1x, 2x, 3x.
const ( IconSize1x IconSizeMultiple = 1 IconSize2x IconSizeMultiple = 2 IconSize3x IconSizeMultiple = 3 )
func (IconSizeMultiple) Suffix ¶
func (m IconSizeMultiple) Suffix() string
Suffix returns the filename suffix appropriate for the icon size multiple.
type InfoPlist ¶
type InfoPlist struct {
CFBundleIdentifier string
CFBundleName string
CFBundleExecutable string
CFBundleIconFile string
CFBundlePackageType string
LSMinimumSystemVersion string
CFBundleDisplayName string
CFBundleVersion string
XPCService *XPCServicePlist
Raw map[string]any
}
InfoPlist represents the contents of a macOS Info.plist file. The struct fields represent common keys found in such files and are extracted from the Raw map for convenience and use within this package.
func (InfoPlist) MarshalPlist ¶
func (InfoPlist) MarshalYAML ¶
type NativeMessagingConfig ¶
type NativeMessagingConfig struct {
Name string `json:"name"`
Description string `json:"description"`
Path string `json:"path"`
Type string `json:"type"` // "stdio" or one of the other allowed communication types
AllowedOrigins []string `json:"allowed_origins,omitempty"` // chrome-extension://<extension-id>/
AllowedExtensions []string `json:"allowed_extensions,omitempty"` // firefox extension ids
}
NativeMessagingConfig represents the configuration for a native messaging host.
func (*NativeMessagingConfig) AppendChromeOrigin ¶
func (nm *NativeMessagingConfig) AppendChromeOrigin(extensionID string)
AppendChromeOrigin appends the specified Chrome extension ID to the list of allowed origins.
func (*NativeMessagingConfig) Validate ¶
func (nm *NativeMessagingConfig) Validate(browser BrowserType) Step
Validate validates the native messaging configuration for the specified browser.
func (*NativeMessagingConfig) ValidateChrome ¶
func (nm *NativeMessagingConfig) ValidateChrome() error
ValidateChrome validates the native messaging configuration for Chrome.
type PerFileEntitlements ¶
type PerFileEntitlements struct {
// contains filtered or unexported fields
}
PerFileEntitlements represents a set of macOS app entitlements that are specific to individual files within an app bundle. These are specified as YAML. The key should be the file within the bundle and the value is the entitlements dictionary for that file. The file name can be either the base name (eg. "executable") or the full path within the bundle (e.g. "Contents/MacOS/executable").
func (PerFileEntitlements) For ¶
func (e PerFileEntitlements) For(path string) (Entitlements, bool)
For returns the entitlements for the specified path or nil if none exist. It will first look for the base name of the path and then the full path.
func (PerFileEntitlements) MarshalPlist ¶
func (e PerFileEntitlements) MarshalPlist() (any, error)
func (PerFileEntitlements) MarshalYAML ¶
func (e PerFileEntitlements) MarshalYAML() (any, error)
func (*PerFileEntitlements) UnmarshalYAML ¶
func (e *PerFileEntitlements) UnmarshalYAML(node *yaml.Node) error
type PkgBuild ¶
type PkgBuild struct {
BuildDir string `yaml:"build_dir"` // Directory to use for building the package
Identifier string `yaml:"identifier"` // Package identifier, e.g. com.cloudeng.myapp
Version string `yaml:"version"` // Package version, e.g. 1.0.0
InstallLocation string `yaml:"install_location"` // Installation location, e.g. /Applications/MyApp.app
}
PkgBuild represents the pkgbuild tool and its configuration.
func (PkgBuild) CopyApplication ¶
CopyApplication returns a Step that copies the specified application bundle to the Applications directory within the package build root.
func (PkgBuild) CopyLibrary ¶
CopyLibrary returns a Step that copies the specified library directory to the Library directory within the package build root. Note that this is one way of installing files for use by the Installer.
func (PkgBuild) CopyScripts ¶
CopyScripts returns a Step that copies the specified scripts directory to the scripts directory within the package build root.
func (PkgBuild) Create ¶
Create returns the steps required to create the pkgbuild directory structure.
func (PkgBuild) CreateLibrary ¶
CreateLibrary returns a Step that creates the specified library directory
func (PkgBuild) Install ¶
Install returns a Step that installs the package using the system installer command using sudo.
func (PkgBuild) LibraryPath ¶
LibraryPath returns the path to the specified library directory within the package build root.
func (PkgBuild) OutputsPath ¶
OutputsPath returns the path to the outputs directory within the package build root.
func (PkgBuild) ScriptsPath ¶
ScriptsPath returns the path to the scripts directory within the package build root.
func (PkgBuild) WritePlist ¶
func (p PkgBuild) WritePlist(cfg []PkgComponentPlist) Step
WritePlist returns a Step that writes the specified component plist configuration to the component.plist file within the package build root.
type PkgComponentPlist ¶
type PkgComponentPlist struct {
RootRelativeBundlePath string `yaml:"RootRelativeBundlePath" plist:"RootRelativeBundlePath"`
BundleIsRelocatable bool `yaml:"BundleIsRelocatable" plist:"BundleIsRelocatable,omitempty"`
BundleIsVersionChecked bool `yaml:"BundleIsVersionChecked" plist:"BundleIsVersionChecked,omitempty"`
BundleHasStrictIdentifier bool `yaml:"BundleHasStrictIdentifier" plist:"BundleHasStrictIdentifier,omitempty"`
BundleOverwriteAction string `yaml:"BundleOverwriteAction" plist:"BundleOverwriteAction,omitempty"`
BundlePreInstallScriptPath string `yaml:"BundlePreInstallScriptPath" plist:"BundlePreInstallScriptPath,omitempty"`
BundlePostInstallScriptPath string `yaml:"BundlePostInstallScriptPath" plist:"BundlePostInstallScriptPath,omitempty"`
BundleInstallScriptTimeout int `yaml:"BundleInstallScriptTimeout" plist:"BundleInstallScriptTimeout,omitempty"`
}
PkgConfPkgComponentPlist represents the pkgbuild component plist structure.
type ProductBuild ¶
type ProductBuild struct {
PkgBuild
InstallLocation string // target location for the install, e.g. /
GUIXML string // path to the distribution XML file relative to the resources directory
}
ProductBuild represents the productbuild tool.
func (ProductBuild) BuildDistribution ¶
func (p ProductBuild) BuildDistribution(outputPkgPath, signingIdentity string) Step
BuildDistribution returns a Step that creates a product archive using productbuild with the specified distribution XML at outputPkgPath.
func (ProductBuild) CopyResources ¶
func (p ProductBuild) CopyResources(src ...string) []Step
CopyResources returns a Step that copies the specified resource to the resources directory within the product build root.
func (ProductBuild) Create ¶
func (p ProductBuild) Create() []Step
Create returns steps that create the product build directory structure in addition to those created by the embedded PkgBuild.
func (ProductBuild) Install ¶
func (p ProductBuild) Install(outputPath string) Step
Install returns a Step that installs the package using the system installer command.
func (ProductBuild) ResourcesPath ¶
func (p ProductBuild) ResourcesPath() string
ResourcesPath returns the path to the resources directory.
type ProductBuildResources ¶
type ProductBuildResources struct {
GUIXML string `yaml:"gui_xml"` // The distribution XML file.
SigningIdentity string `yaml:"signing_identity"` // The signing identity to use for signing the product.
Resources []string `yaml:"resources"` // paths to additional resources to include in the product build.
Packages []string `yaml:"packages"` // paths to the component packages to include in the product build.
}
ProductBuildResources represents the resources needed to create a productbuild distribution.
type ProductPreInstallRequirements ¶
ProductPreInstallRequirements represents the productbuild pre-install requirements for synthesized packages.
func (ProductPreInstallRequirements) MarshalPlist ¶
func (p ProductPreInstallRequirements) MarshalPlist() (any, error)
func (ProductPreInstallRequirements) MarshalYAML ¶
func (p ProductPreInstallRequirements) MarshalYAML() (any, error)
func (*ProductPreInstallRequirements) UnmarshalYAML ¶
func (p *ProductPreInstallRequirements) UnmarshalYAML(node *yaml.Node) error
type ReformatIcon ¶
ReformatIcon represents a step that reformats an icon to the specified format.
func (ReformatIcon) Convert ¶
func (j ReformatIcon) Convert(format string) Step
Convert converts the input image/icon to the specified format.
type Resources ¶
type Resources struct {
Executable string `yaml:"executable"`
Icons []IconSet `yaml:"icons"` // multiple icon sets can be specified
}
Resources represents the resources needed to build an app bundle.
func (Resources) IconSetSteps ¶
IconSetSteps returns the steps needed to create the icon sets specified in the Resources.
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
func NewSigner ¶
func NewSigner(identity string, entitlements *Entitlements, perFileEntitlements *PerFileEntitlements, arguments []string) Signer
NewSigner creates a new signer. The most specific entitlements for a given path will be used. If no file specific entitlement exists, the global one (if any) is used.
func (Signer) SignPath ¶
SignPath returns a Step that signs the specified path within the specified bundle. If path is empty, the bundle itself is signed.
func (Signer) VerifyPath ¶
VerifyPath returns a Step that verifies the signature of the specified path within the specified bundle. If path is empty, the bundle itself is verified.
type SigningConfig ¶
type SigningConfig struct {
Identity string `yaml:"identity"`
CodesignArguments []string `yaml:"codesign-args"`
Entitlements *Entitlements `yaml:"entitlements"`
PerFileEntitlements *PerFileEntitlements `yaml:"perfile_entitlements"`
}
SigningConfig represents signing related configuration that can be read from a yaml config file.
func (SigningConfig) Signer ¶
func (s SigningConfig) Signer() Signer
Signer returns a Signer based on the configuration.
type Step ¶
type Step interface {
// Run executes the step.
Run(context.Context, *CommandRunner) (StepResult, error)
}
Step represents a single operation that can be executed by the StepRunner.
func FileExists ¶
FileExists returns a Step that checks for the existence of the file.
func IsValidIconSetDir ¶
func IsValidIconSetDir(id IconSetDir) Step
IsValidIsValidIconSetDir returns a Step that checks if the directory has a .iconset extension.
func MkdirAll ¶
MkdirAll returns a Step that creates a directory and all necessary parents using mkdir -p.
func RmdirAll ¶
RmdirAll returns a Step that removes an app bundle and all its contents using rm -rf.
func StepFunc ¶
func StepFunc(f func(context.Context, *CommandRunner) (StepResult, error)) Step
StepFunc is a helper to create Steps from functions.
func WriteFile ¶
WriteFile returns a Step that writes data to the specified path with the specified permissions.
func WriteJSONFile ¶
WriteJSONFile returns a Step that marshals v to JSON and writes it to the specified path with the specified permissions.
func WritePlistFile ¶
WritePlistFile returns a Step that marshals v to a plist and writes it to the specified path with the specified permissions.
type StepResult ¶
type StepResult struct {
// contains filtered or unexported fields
}
func NewStepResult ¶
func NewStepResult(executable string, args []string, output []byte, err error) StepResult
func (*StepResult) Args ¶
func (le *StepResult) Args() []string
func (*StepResult) CommandLine ¶
func (le *StepResult) CommandLine() string
func (*StepResult) Duration ¶
func (le *StepResult) Duration() time.Duration
func (*StepResult) Error ¶
func (le *StepResult) Error() error
func (*StepResult) Executable ¶
func (le *StepResult) Executable() string
func (*StepResult) Output ¶
func (le *StepResult) Output() string
func (*StepResult) String ¶
func (le *StepResult) String() string
type StepRunner ¶
type StepRunner struct {
// contains filtered or unexported fields
}
StepRunner manages and executes a series of Steps.
func NewRunner ¶
func NewRunner(opts ...StepRunnerOption) *StepRunner
NewRunner creates a new StepRunner with the provided options.
func (*StepRunner) AddSteps ¶
func (r *StepRunner) AddSteps(steps ...Step) *StepRunner
AddSteps adds one or more steps to the StepRunner.
func (*StepRunner) Run ¶
func (r *StepRunner) Run(ctx context.Context, cmdRunner *CommandRunner) RunResult
Run executes all added steps in sequence and returns a RunResult.
type StepRunnerOption ¶
type StepRunnerOption func(o *stepRunnerOptions)
StepRunnerOption configures a StepRunner.
func WithStepTiming ¶
func WithStepTiming(timing bool) StepRunnerOption
type SwiftApp ¶
type SwiftApp struct {
// contains filtered or unexported fields
}
SwiftApp represents the swift build tool.
func NewSwiftApp ¶
NewSwiftApp creates a new SwiftApp instance rooted at the specified directory.
func (SwiftApp) CopyIcons ¶
CopyIcons returns steps to copy the specified icons into the swift build tree's Resources directory.
func (SwiftApp) ExecutablePath ¶
ExecutablePath returns the path to the specified executable within the swift build tree.
type XPCServicePlist ¶
type XPCServicePlist struct {
ServiceName string
}
XPCServicePlist represents the contents of an XPCService dictionary within an Info.plist file. The Raw field contains the full dictionary contents while the ServiceName field is extracted for convenience.