Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
energye
energy
提交
44340118
energy
项目概览
energye
/
energy
通知
13
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
energy
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
44340118
编写于
9月 25, 2023
作者:
Z
zhangli10
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
command-line: install, package, darwin upx
上级
fcb8301e
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
52 addition
and
14 deletion
+52
-14
cmd/internal/assets/assets.go
cmd/internal/assets/assets.go
+9
-9
cmd/internal/command/command.go
cmd/internal/command/command.go
+3
-2
cmd/internal/package.go
cmd/internal/package.go
+1
-0
cmd/internal/packager/pkg_app_darwin.go
cmd/internal/packager/pkg_app_darwin.go
+37
-0
cmd/internal/packager/pkg_dpkg_linux.go
cmd/internal/packager/pkg_dpkg_linux.go
+1
-3
cmd/internal/project/project.go
cmd/internal/project/project.go
+1
-0
未找到文件。
cmd/internal/assets/assets.go
浏览文件 @
44340118
...
...
@@ -29,27 +29,27 @@ const (
)
// AssetsPath 返回配置资源目录
func
AssetsPath
(
proj
ectData
*
project
.
Project
,
file
string
)
string
{
return
filepath
.
ToSlash
(
filepath
.
Join
(
proj
ectData
.
AssetsDir
,
file
))
func
AssetsPath
(
proj
*
project
.
Project
,
file
string
)
string
{
return
filepath
.
ToSlash
(
filepath
.
Join
(
proj
.
AssetsDir
,
file
))
}
// BuildOutPath 返回固定构建输出目录 $current/build
func
BuildOutPath
(
proj
ectData
*
project
.
Project
)
string
{
if
proj
ectData
.
AppType
==
project
.
AtHelper
{
return
proj
ectData
.
ProjectPath
func
BuildOutPath
(
proj
*
project
.
Project
)
string
{
if
proj
.
AppType
==
project
.
AtHelper
{
return
proj
.
ProjectPath
}
return
filepath
.
Join
(
proj
ectData
.
ProjectPath
,
"build"
)
return
filepath
.
Join
(
proj
.
ProjectPath
,
"build"
)
}
// ReadFile
// 读取文件,根据项目配置先在本地目录读取,如果读取失败,则在内置资源目录读取
func
ReadFile
(
proj
ectData
*
project
.
Project
,
assetsFSPath
,
file
string
)
([]
byte
,
error
)
{
func
ReadFile
(
proj
*
project
.
Project
,
assetsFSPath
,
file
string
)
([]
byte
,
error
)
{
var
(
content
[]
byte
err
error
)
if
proj
ectData
!=
nil
{
localFilePath
:=
AssetsPath
(
proj
ectData
,
file
)
if
proj
!=
nil
{
localFilePath
:=
AssetsPath
(
proj
,
file
)
content
,
err
=
os
.
ReadFile
(
localFilePath
)
}
if
errors
.
Is
(
err
,
fs
.
ErrNotExist
)
||
content
==
nil
{
...
...
cmd/internal/command/command.go
浏览文件 @
44340118
...
...
@@ -49,8 +49,9 @@ type Install struct {
}
type
Package
struct
{
Path
string
`short:"p" long:"path" description:"Project path, default current path. Can be configured in energy.json" default:""`
Clean
bool
`short:"c" long:"clean" description:"Clear configuration and regenerate the default configuration"`
Path
string
`short:"p" long:"path" description:"Project path, default current path. Can be configured in energy.json" default:""`
Clean
bool
`short:"c" long:"clean" description:"Clear configuration and regenerate the default configuration"`
Pkgbuild
bool
`long:"pkg" description:"Using pkgbuild to create pkg development installation packages"`
}
type
Env
struct
{
...
...
cmd/internal/package.go
浏览文件 @
44340118
...
...
@@ -43,6 +43,7 @@ func runPackage(c *command.Config) error {
return
err
}
else
{
proj
.
Clean
=
c
.
Package
.
Clean
proj
.
Dpkg
.
Pkgbuild
=
c
.
Package
.
Pkgbuild
if
err
=
packager
.
GeneraInstaller
(
proj
);
err
!=
nil
{
return
err
}
...
...
cmd/internal/packager/pkg_app_darwin.go
浏览文件 @
44340118
...
...
@@ -67,12 +67,14 @@ var (
macCefHelperPlugin
,
macCefHelpersRenderer
,
}
projectPath
string
)
func
GeneraInstaller
(
proj
*
project
.
Project
)
error
{
appRoot
:=
fmt
.
Sprintf
(
"darwin/%s.app"
,
proj
.
Name
)
buildOutDir
:=
assets
.
BuildOutPath
(
proj
)
buildOutDir
=
filepath
.
Join
(
buildOutDir
,
appRoot
)
projectPath
=
proj
.
ProjectPath
if
!
tools
.
IsExist
(
buildOutDir
)
{
if
err
:=
os
.
MkdirAll
(
buildOutDir
,
0755
);
err
!=
nil
{
return
fmt
.
Errorf
(
"unable to create directory: %w"
,
err
)
...
...
@@ -96,6 +98,11 @@ func GeneraInstaller(proj *project.Project) error {
if
err
:=
copyHelperFile
(
proj
,
appRoot
);
err
!=
nil
{
return
err
}
if
proj
.
Dpkg
.
Pkgbuild
{
if
err
:=
pkgbuild
(
proj
,
appRoot
);
err
!=
nil
{
return
err
}
}
return
nil
}
...
...
@@ -192,7 +199,36 @@ func copyFrameworkFile(proj *project.Project, appRoot string) error {
if
err
:=
copyFiles
(
proj
,
cefDir
,
outCEF
);
err
!=
nil
{
return
err
}
return
nil
}
// pkgbuild --root demo.app --identifier com.demo.demo --version 1.0.0 --install-location /Applications/demo.app demo.pkg
func
pkgbuild
(
proj
*
project
.
Project
,
appRoot
string
)
error
{
proj
.
AppType
=
project
.
AtApp
proj
.
ProjectPath
=
projectPath
buildOutDir
:=
assets
.
BuildOutPath
(
proj
)
cmdWorkDir
:=
filepath
.
Join
(
buildOutDir
,
"darwin"
)
term
.
Logger
.
Info
(
"Generate app pkgbuild"
,
term
.
Logger
.
Args
(
"cmd work dir"
,
cmdWorkDir
))
// remove xxx.pkg
os
.
Remove
(
filepath
.
Join
(
cmdWorkDir
,
fmt
.
Sprintf
(
"%s.pkg"
,
proj
.
Name
)))
cmd
:=
command
.
NewCMD
()
//cmd.IsPrint = false
cmd
.
Dir
=
cmdWorkDir
cmd
.
MessageCallback
=
func
(
bytes
[]
byte
,
err
error
)
{
msg
:=
string
(
bytes
)
if
msg
!=
""
{
println
(
msg
)
}
}
var
args
=
[]
string
{
"--root"
,
fmt
.
Sprintf
(
"%s.app"
,
proj
.
Name
),
"--identifier"
,
fmt
.
Sprintf
(
"com.%s.%s"
,
proj
.
PList
.
CompanyName
,
proj
.
PList
.
ProductName
),
"--version"
,
proj
.
PList
.
CFBundleVersion
,
"--install-location"
,
fmt
.
Sprintf
(
"/Applications/%s.app"
,
proj
.
Name
),
fmt
.
Sprintf
(
"%s.pkg"
,
proj
.
Name
)}
cmd
.
Command
(
"pkgbuild"
,
args
...
)
cmd
.
Close
()
// remove xxx.app
os
.
Remove
(
filepath
.
Join
(
buildOutDir
,
appRoot
))
return
nil
}
...
...
@@ -259,6 +295,7 @@ func createApp(proj *project.Project, appRoot string) error {
term
.
Logger
.
Info
(
"Generate app create app dir: "
+
appRoot
)
buildOutDir
:=
assets
.
BuildOutPath
(
proj
)
appDir
:=
filepath
.
Join
(
buildOutDir
,
appRoot
)
os
.
Remove
(
appDir
)
// Contents
contents
:=
filepath
.
Join
(
appDir
,
appContents
)
if
err
:=
os
.
MkdirAll
(
contents
,
0755
);
err
!=
nil
{
...
...
cmd/internal/packager/pkg_dpkg_linux.go
浏览文件 @
44340118
...
...
@@ -116,9 +116,7 @@ func dpkgB(proj *project.Project) (string, error) {
err
=
e
}
}
if
tools
.
IsExist
(
outFile
)
{
os
.
Remove
(
outFile
)
}
os
.
Remove
(
outFile
)
var
args
=
[]
string
{
"-b"
,
app
,
debName
}
cmd
.
Command
(
"dpkg"
,
args
...
)
cmd
.
Close
()
...
...
cmd/internal/project/project.go
浏览文件 @
44340118
...
...
@@ -158,6 +158,7 @@ type DPKG struct {
Compress
string
`json:"compress"`
//压纹CEF, 当前仅支持7z/a压缩,""(空)时不启用压缩 默认: 7za
UseCompress
bool
`json:"-"`
//如果支持配置的, true=使用压缩
CompressFile
string
`json:"-"`
//压缩后的文件完全目录
Pkgbuild
bool
`json:"-"`
// 生成pkg安装包
}
type
PList
struct
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录