packager

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const SELECT_SITE_URL_STMT = "SELECT option_value FROM %s WHERE option_name = 'siteurl';"

This is the SQL statement used to select the site url from the database.

Variables

View Source
var (
	ErrCannotCreateClient      = errors.New("cannot create client")
	ErrCannotDetermineSiteInfo = errors.New("cannot determine site info")
	ErrCannotBuildOperations   = errors.New("cannot build operations")
	ErrCannotCreateZipFile     = errors.New("cannot create zip file")
	ErrCannotRunOperations     = errors.New("cannot run operations")
)
View Source
var ErrCannotParseWPConfig = errors.New("error parsing wp-config.php file")
View Source
var ErrNoOperations = errors.New("no operations to run")

Functions

This section is empty.

Types

type Builder

type Builder struct {
	// contains filtered or unexported fields
}

Builder is responsible for building the operations that will be run by the Runner.

func (*Builder) Build

func (b *Builder) Build(info SiteInfo) ([]operations.Operation, error)

type OperationsBuilder

type OperationsBuilder interface {
	Build(info SiteInfo) ([]operations.Operation, error)
}

OperationsBuilder builds all the operations needed to package a WordPress site. They will be run by the OperationsRunner.

type OperationsRunner

type OperationsRunner interface {
	Run(operations []operations.Operation, writer io.Writer) error
}

OperationsRunner runs all the operations needed to package a WordPress site. The operations are first built by the OperationsBuilder. Typically, the writer would be a zip file to output to.

type Packager

type Packager struct {
	// contains filtered or unexported fields
}

Packager is the orchestrator of the packaging process. It uses an OperationsBuilder to build the operations, and an OperationsRunner to run them. It is also responsible for creating the zip file to output to.

func NewPackager

func NewPackager(sshCredentials sftp.SSHCredentials, siteUrl types.SiteUrl, publicPath types.PublicPath) (*Packager, error)

NewPackager is the constructor for Packager. It will create the default implementations of OperationsBuilder and OperationsRunner.

func (*Packager) PackageWP

func (p *Packager) PackageWP(outputFilename string) error

PackageWP packages a WordPress site. It will build the operations, run them, and output the zip file.

type Prompter

type Prompter interface {
	Prompt(question string) string
}

type Runner

type Runner struct{}

Runner is responsible for running the operations that will create the zip archive. It runs the operations sequentially, and writes the files that they send one by one into the zip archive.

func (*Runner) Run

func (r *Runner) Run(ops []operations.Operation, writer io.Writer) error

type RuntimePrompter

type RuntimePrompter struct{}

RuntimePrompter is a Prompter that prompts the user at runtime for input.

func (*RuntimePrompter) Prompt

func (p *RuntimePrompter) Prompt(question string) string

Prompt prompts the user with the given question and returns their response.

func (*RuntimePrompter) PromptForPassword

func (p *RuntimePrompter) PromptForPassword(question string) string

PromptForPassword prompts the user for input without echoing the input to the terminal.

type SiteInfo

type SiteInfo struct {
	// contains filtered or unexported fields
}

SiteInfo contains all the information needed to package a WordPress site.

func DetermineSiteInfo

func DetermineSiteInfo(siteUrl types.SiteUrl, publicPath types.PublicPath, parser WPConfigParser, runner sftp.RemoteCommandRunner, prompter Prompter) (SiteInfo, error)

DetermineSiteInfo determines the site info needed to package a WordPress site. Some of the information is determined at runtime, such as the database credentials.

type WPConfigParser

type WPConfigParser interface {
	ParseWPConfig(publicPath types.PublicPath) (parser.WPConfigFields, error)
}

Jump to

Keyboard shortcuts

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