nuwa

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2021 License: Apache-2.0 Imports: 18 Imported by: 0

README

nuwa(女娲)

功能

提供打包服务,支持

  • Windows:打包成Windows的安装程序
  • Android:打包成Android的安装程序

为什么叫女娲

女娲,中国上古神话中的创世女神。 又称娲皇、女阴,史记女娲氏,是华夏民族人文先始,是福佑社稷之正神。 相传女娲造人,一日中七十化变,以黄泥仿照自己抟土造人,创造人类社会并建立婚姻制度;因世间天塌地陷,于是熔彩石以补苍天,斩鳖足以立四极,留下了女娲补天的神话传说。 女娲不但是补天救世的英雌和抟土造人的女神,还是一个创造万物的自然之神,神通广大化生万物,每天至少能创造出七十样东西。她开世造物,因此被称为大地之母,是被民间广泛而又长久崇拜的创世神和始母神。

从某种意义上讲,女娲代表了从无到有的过程(女娲造人),这和打包过程非常相似

Documentation

Index

Constants

View Source
const (
	// DefaultAppNameKey 默认语言键
	DefaultAppNameKey string = "default"
)

Variables

View Source
var ErrorNotSupportPackage = &gox.CodeError{ErrorCode: 101, Message: "不支持的打包类型"}

ErrorNotSupportPackage 不支持的打包类型

Functions

This section is empty.

Types

type Android

type Android struct {
	BasePackager

	// Name 应用名称
	Name map[string]string `json:"name"`
	// Package 包名
	Package string `json:"package"`
	// Icon 图标
	Icon transfer.File `json:"icon"`
	// Version 版本号
	Version string `json:"version"`
	// Sign 签名
	Sign AndroidAppSign `json:"sign"`
}

Android APK打包信息

func (Android) String

func (a Android) String() string

type AndroidAppSign

type AndroidAppSign struct {
	// KeystoreFile 密钥文件
	KeystoreFile transfer.File `json:"keystoreFile"`
	// StorePass 密码
	StorePass string `json:"storePass"`
	// DigestAlg 加密算法
	DigestAlg string `default:"SHA1" json:"digestAlg"`
	// SigAlg 签名算法
	SigAlg string `default:"SHA1withRSA" json:"sigAlg"`
	// Alias 别名
	Alias string `json:"alias"`
}

AndroidAppSign 安卓签名

type BasePackager added in v1.1.5

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

BasePackager 基础打包

func (*BasePackager) AddCleanupPaths added in v1.1.5

func (bp *BasePackager) AddCleanupPaths(paths ...string)

func (*BasePackager) Cleanup added in v1.1.5

func (bp *BasePackager) Cleanup() (err error)

type Client

type Client struct {
	class100.Client

	// Endpoint 地址
	Endpoint string `default:"https://nuwa.class100.com" json:"endpoint"`
}

Client 女娲打包系统

func New

func New(endpoint string, accessKey string, secretKey string) *Client

New 创建一个新的女娲客户端

func (*Client) Package

func (c *Client) Package(pkg *Package, environment core.Environment, version class100.ApiVersion) (rsp Response, err error)

func (Client) String

func (c Client) String() string

type Notify

type Notify struct {
	// Url 回调地址
	Url string `json:"url" validate:"required"`
	// Scheme JWT的验证前缀
	Scheme string `default:"Bearer" json:"scheme" validate:"required"`
	// Token JWT验证授权码
	Token string `json:"token" validate:"required"`
	// Payload 透传数据
	Payload interface{} `json:"payload"`
}

Notify 通知,通过JWT回调

func NewNotify

func NewNotify(url string, scheme string, token string, payload interface{}) Notify

NewNotify 创建一个新的通知

func (Notify) String

func (n Notify) String() string

type NotifyRequest

type NotifyRequest struct {
	// Status 打包状态
	Status PackageStatus `json:"status"`
	// SrcFile 源文件
	SrcFile transfer.File `json:"srcFile"`
	// DestFile 打包后的文件
	DestFile transfer.File `json:"destFile"`
	// Payload 透传数据
	Payload interface{} `json:"payload"`
}

NotifyRequest 回调请求数据

type Package

type Package struct {
	// Type 打包类型
	Type PackageType `json:"type" validate:"required,oneof=windows mac android"`
	// MaxRetry 最大重试次数
	MaxRetry int `default:"10" json:"maxRetry" validate:"omitempty,min=1,max=100"`
	// SrcFile 源文件
	SrcFile transfer.File `json:"srcFile" validate:"required"`
	// DestFile 打包后的文件
	DestFile transfer.File `json:"destFile" validate:"required"`
	// Replaces 文件替换
	Replaces []replace.Replace `json:"replaces" validate:"omitempty,dive"`
	// Notify 通知
	Notify Notify `json:"notify" validate:"omitempty,structonly"`
	// Packager 真正的打包者
	Packager interface{} `json:"packager" validate:"required"`
}

Package 打包请求

func NewAndroidPackage

func NewAndroidPackage(
	android Android,
	maxRetry int,
	srcFile transfer.File, destFile transfer.File,
	notify Notify,
	replaces ...replace.Replace,
) *Package

NewAndroidPackage 创建一个Android打包

func NewPackage

func NewPackage(
	packageType PackageType,
	maxRetry int,
	srcFile transfer.File, destFile transfer.File,
	notify Notify,
	packager interface{},
	replaces ...replace.Replace,
) *Package

NewPackage 创建一个打包

func NewSimpleAndroidPackage

func NewSimpleAndroidPackage(
	android Android,
	srcFile transfer.File, destFile transfer.File,
	notify Notify,
	replaces ...replace.Replace,
) *Package

NewSimpleAndroidPackage 创建一个简单的Android打包

func NewSimpleWindowsPackage

func NewSimpleWindowsPackage(
	windows Windows,
	srcFile transfer.File, destFile transfer.File,
	notify Notify,
	replaces ...replace.Replace,
) *Package

NewSimpleWindowsPackage 创建一个简单的Windows打包

func NewWindowsPackage

func NewWindowsPackage(
	windows Windows,
	maxRetry int,
	srcFile transfer.File, destFile transfer.File,
	notify Notify,
	replaces ...replace.Replace,
) *Package

NewWindowsPackage 创建一个Windows打包

func (*Package) Build

func (pkg *Package) Build(rootPath string, packager Packager) (err error)

func (*Package) Name added in v1.0.3

func (pkg *Package) Name() (name string)

func (Package) String

func (pkg Package) String() string

func (*Package) Tag

func (pkg *Package) Tag(environment core.Environment) (tag string, err error)

func (*Package) UnmarshalJSON

func (pkg *Package) UnmarshalJSON(jsonBytes []byte) (err error)

type PackageStatus

type PackageStatus string

PackageStatus 打包结果

const (
	// 打包状态
	// PackageStatusSuccess 打包成功
	PackageStatusSuccess PackageStatus = "success"
	// PackageStatusFailed 打包失败
	PackageStatusFailed PackageStatus = "failed"
)

type PackageType

type PackageType string

PackageType 打包类型

const (
	// 打包类型
	// PackageTypeWindows Windows打包
	PackageTypeWindows PackageType = "windows"
	// PackageTypeMac Mac打包
	PackageTypeMac PackageType = "mac"
	// PackageTypeAndroid 安卓打包
	PackageTypeAndroid PackageType = "android"
	// PackageTypeIOS iOS打包
	PackageTypeIOS PackageType = "ios"
)

type Packager

type Packager interface {
	// Init 初始化阶段,主要做一些打包前的初始化工作,比如各种变量的初始化
	Init() (err error)

	// Decode 解码阶段,主要是把源文件解包(如果是Zip文件就解压,如果是APK就反编译,以此类推)
	Decode(inputFilename string, packageDir string) (err error)

	// Modify 修改阶段,比如替换图标、包名等
	Modify(packageDir string) (err error)

	// Build 打包阶段,在修改阶段的基础上,把处理好的程序打包成最终的包(如Exe、APK、DMG以及IPA等)
	Build(packageDir string, outputFilename string) (err error)

	// Cleanup 清理阶段,做最后的清理工作,比如删除打包过程中的中间文件
	Cleanup() (err error)

	// AddCleanupPaths 添加清理路径
	AddCleanupPaths(paths ...string)
}

type Request

type Request struct {
	class100.Request

	// Package 打包参数
	Package *Package `json:"package" validate:"required,structonly"`
}

Request 女娲打包请求

func (Request) String

func (r Request) String() string

type Response

type Response struct {
	// 编号
	Id string `json:"id"`
	// 关键信息
	Key string `json:"key"`
}

Response 响应

func (Response) String

func (r Response) String() string

type Windows

type Windows struct {
	BasePackager

	// ProductId 产品的唯一标识
	ProductId string `json:"productId" validate:"required,start_with_alpha"`
	// ProductName 安装过程中显示的应用程序名称
	ProductName string `json:"productName" validate:"omitempty"`
	// ProductVersion 安装过程中显示的版本号
	ProductVersion string `json:"productVersion" validate:"omitempty"`
	// ProductPublisher 应用程序出版人
	ProductPublisher string `json:"productPublisher" validate:"omitempty"`
	// ProductWebsite 应用程序网站
	ProductWebsite string `json:"productWebsite" validate:"omitempty,url"`
	// RunFilename 安装目录下Exe名称
	RunFilename string `json:"runFilename" validate:"omitempty"`
	// ShortcutName 安装完成后快捷方式的名称
	ShortcutName string `json:"shortcutName" validate:"omitempty"`
	// InstallDirName 安装目录文件夹名
	InstallDirName string `json:"installDirName" validate:"omitempty"`
	// InstallIcon 安装图标
	InstallIcon transfer.File `json:"installIcon" validate:"omitempty,structonly"`
	// UninstallIcon 卸载图标
	UninstallIcon transfer.File `json:"uninstallIcon" validate:"omitempty,structonly"`
	// UninstallMessage 卸载时的提示语句
	UninstallMessage string `json:"uninstallMessage" validate:"omitempty"`
	// UninstallFinishMessage 卸载完成是的提示语句
	UninstallFinishMessage string `json:"uninstallFinishMessage" validate:"omitempty"`
}

Windows Windows打包信息

func (Windows) String

func (w Windows) String() string

Jump to

Keyboard shortcuts

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