Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
energye
energy
提交
7674c729
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,发现更多精彩内容 >>
提交
7674c729
编写于
9月 05, 2023
作者:
yanghye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
energy-command-line, 优化命令 install .
上级
a94ad940
变更
8
隐藏空白更改
内联
并排
Showing
8 changed file
with
94 addition
and
49 deletion
+94
-49
cmd/energy/energy.go
cmd/energy/energy.go
+1
-1
cmd/internal/command/command.go
cmd/internal/command/command.go
+4
-0
cmd/internal/install.go
cmd/internal/install.go
+2
-2
cmd/internal/install/install.go
cmd/internal/install/install.go
+76
-0
cmd/internal/install/install_cef_framework.go
cmd/internal/install/install_cef_framework.go
+2
-12
cmd/internal/install/install_golang.go
cmd/internal/install/install_golang.go
+3
-14
cmd/internal/install/install_nsis.go
cmd/internal/install/install_nsis.go
+5
-19
cmd/internal/progress-bar/bar.go
cmd/internal/progress-bar/bar.go
+1
-1
未找到文件。
cmd/energy/energy.go
浏览文件 @
7674c729
...
...
@@ -62,7 +62,7 @@ func main() {
fmt
.
Fprintf
(
os
.
Stderr
,
"%s
\n
%s"
,
command
.
UsageLine
,
command
.
Long
)
os
.
Exit
(
1
)
}
fmt
.
Println
(
"Energy executing:"
,
command
.
Short
)
fmt
.
Println
(
command
.
Short
)
if
err
:=
command
.
Run
(
cc
);
err
!=
nil
{
fmt
.
Fprint
(
os
.
Stderr
,
err
.
Error
()
+
"
\n
"
)
os
.
Exit
(
1
)
...
...
cmd/internal/command/command.go
浏览文件 @
7674c729
...
...
@@ -34,6 +34,10 @@ type Install struct {
Download
string
`short:"d" long:"download" description:"Download Source, 0:gitee or 1:github, Default empty" default:""`
All
string
`short:"a" long:"all" description:"Install all, skip installation prompts (Y/n), default empty:n" default:""`
CEF
string
`short:"c" long:"cef" description:"Install system supports CEF version, provide 4 options, default empty. default, windows7, gtk2, flash" default:""`
IGolang
bool
ICEF
bool
INSIS
bool
IUPX
bool
}
type
Package
struct
{
...
...
cmd/internal/install.go
浏览文件 @
7674c729
...
...
@@ -17,7 +17,7 @@ import (
var
CmdInstall
=
&
command
.
Command
{
UsageLine
:
"install -p [path] -v [version] -n [name] -d [download] -a [all] -c [cef]"
,
Short
:
"Automatic
ally configure the CEF and Energy framework
"
,
Short
:
"Automatic
installation and configuration of the energy framework complete development environment
"
,
Long
:
`
-p Installation directory Default current directory
-v Specifying a version number,Default latest.\
...
...
@@ -31,7 +31,7 @@ var CmdInstall = &command.Command{
87 : CEF 87.1.14 is the last one to support Flash.
. Execute default command
Automatic
ally install and configure the Energy
development environment.
Automatic
installation and configuration of the energy framework complete
development environment.
Installation package is downloaded over the network during the installation process.
According to the prompt (Y), install Golang、CEF(Chromium Embedded Framework)、NSIS, If installed, skip.
`
,
...
...
cmd/internal/install/install.go
浏览文件 @
7674c729
...
...
@@ -25,6 +25,7 @@ import (
"net/http"
"os"
"path/filepath"
"runtime"
"strconv"
"strings"
)
...
...
@@ -42,6 +43,7 @@ type downloadInfo struct {
func
Install
(
c
*
command
.
Config
)
{
// 初始配置和安装目录
initInstall
(
c
)
willInstall
:=
checkInstallEnv
(
c
)
var
(
goRoot
string
goSuccessCallback
func
()
...
...
@@ -50,6 +52,15 @@ func Install(c *command.Config) {
nsisRoot
string
nsisSuccessCallback
func
()
)
if
len
(
willInstall
)
>
0
{
println
(
"Following will be installed"
)
for
_
,
name
:=
range
willInstall
{
println
(
"
\t
"
,
name
)
}
println
(
"Press Enter to start installation"
)
var
s
string
fmt
.
Scanln
(
&
s
)
}
// 安装Go开发环境
goRoot
,
goSuccessCallback
=
installGolang
(
c
)
// 安装CEF二进制框架
...
...
@@ -70,6 +81,7 @@ func Install(c *command.Config) {
if
cefFrameworkRoot
!=
""
{
env
.
SetEnergyHomeEnv
(
cefFrameworkRoot
)
}
println
(
"-----------------------------------------------------"
)
// success 输出
if
nsisSuccessCallback
!=
nil
{
nsisSuccessCallback
()
...
...
@@ -80,6 +92,17 @@ func Install(c *command.Config) {
if
cefFrameworkSuccessCallback
!=
nil
{
cefFrameworkSuccessCallback
()
}
// end
//if len(willInstall) > 0 {
// print("was installed: ")
// for i, name := range willInstall {
// if i > 0 {
// print("|")
// }
// print(name)
// }
// println()
//}
}
func
cefInstallPathName
(
c
*
command
.
Config
)
string
{
...
...
@@ -94,6 +117,59 @@ func nsisInstallPathName(c *command.Config) string {
return
filepath
.
Join
(
c
.
Install
.
Path
,
"nsis"
)
}
func
checkInstallEnv
(
c
*
command
.
Config
)
(
result
[]
string
)
{
skip
:=
strings
.
ToLower
(
c
.
Install
.
All
)
==
"y"
var
check
=
func
(
chkInstall
func
()
bool
,
name
string
,
yes
func
())
{
if
chkInstall
()
{
println
(
" "
,
name
,
"installed"
)
}
else
{
fmt
.
Printf
(
" %s: Not installed, install %s ? (Y/n): "
,
name
,
name
)
var
s
string
if
!
skip
{
fmt
.
Scanln
(
&
s
)
// 跳过输入Y,
}
else
{
s
=
"y"
}
if
strings
.
ToLower
(
s
)
==
"y"
{
result
=
append
(
result
,
name
)
yes
()
}
else
{
println
(
" "
,
name
,
"install skip"
)
}
}
}
// go
check
(
func
()
bool
{
return
tools
.
CommandExists
(
"go"
)
},
"Golang"
,
func
()
{
c
.
Install
.
IGolang
=
true
})
// nsis
check
(
func
()
bool
{
if
consts
.
IsWindows
&&
runtime
.
GOARCH
==
"amd64"
{
return
tools
.
CommandExists
(
"makensis"
)
}
else
{
println
(
" Non Windows amd64 skipping NSIS"
)
return
false
}
},
"NSIS"
,
func
()
{
c
.
Install
.
INSIS
=
true
})
// cef
check
(
func
()
bool
{
return
tools
.
CheckCEFDir
()
},
"CEF Framework"
,
func
()
{
c
.
Install
.
ICEF
=
true
})
// upx
check
(
func
()
bool
{
return
tools
.
CommandExists
(
"upx"
)
},
"UPX"
,
func
()
{
c
.
Install
.
IUPX
=
true
})
return
}
func
initInstall
(
c
*
command
.
Config
)
{
if
c
.
Install
.
Path
==
""
{
// current dir
...
...
cmd/internal/install/install_cef_framework.go
浏览文件 @
7674c729
...
...
@@ -26,19 +26,9 @@ import (
)
func
installCEFFramework
(
c
*
command
.
Config
)
(
string
,
func
())
{
if
tools
.
CheckCEFDir
()
{
println
(
"CEF Framework installed"
)
if
!
c
.
Install
.
ICEF
{
return
""
,
nil
}
print
(
"CEF Framework is not installed. Determine whether to install CEF Framework? Y/n: "
)
var
s
string
if
strings
.
ToLower
(
c
.
Install
.
All
)
!=
"y"
{
fmt
.
Scanln
(
&
s
)
if
strings
.
ToLower
(
s
)
!=
"y"
{
println
(
"CEF Framework install exit"
)
return
""
,
nil
}
}
// 获取提取文件配置
extractData
,
err
:=
tools
.
HttpRequestGET
(
consts
.
DownloadExtractURL
)
if
err
!=
nil
{
...
...
@@ -246,7 +236,7 @@ func installCEFFramework(c *command.Config) (string, func()) {
}
}
return
installPathName
,
func
()
{
println
(
"
\n
CEF Installed Successfully
\n
Installed v
ersion:"
,
c
.
Install
.
Version
,
liblclVersion
)
println
(
"
\n
CEF Installed Successfully
V
ersion:"
,
c
.
Install
.
Version
,
liblclVersion
)
if
liblclModule
==
nil
{
println
(
"hint: liblcl module"
,
liblclModuleName
,
`is not configured in the current version, You need to use built-in binary build. [go build -tags="tempdll"]`
)
}
...
...
cmd/internal/install/install_golang.go
浏览文件 @
7674c729
...
...
@@ -19,25 +19,14 @@ import (
"os"
"path/filepath"
"runtime"
"strings"
)
// 下载go并配置安装
func
installGolang
(
c
*
command
.
Config
)
(
string
,
func
())
{
if
tools
.
CommandExists
(
"go"
)
{
println
(
"Golang installed"
)
if
!
c
.
Install
.
IGolang
{
return
""
,
nil
}
print
(
"Golang not installed, do you want to install Golang? Y/n: "
)
var
s
string
if
strings
.
ToLower
(
c
.
Install
.
All
)
!=
"y"
{
fmt
.
Scanln
(
&
s
)
if
strings
.
ToLower
(
s
)
!=
"y"
{
println
(
"Golang install exit"
)
return
""
,
nil
}
}
s
=
c
.
Install
.
Path
// 安装目录
s
:=
c
.
Install
.
Path
// 安装目录
exts
:=
map
[
string
]
string
{
"darwin"
:
"tar.gz"
,
"linux"
:
"tar.gz"
,
...
...
@@ -87,7 +76,7 @@ func installGolang(c *command.Config) (string, func()) {
ExtractUnTar
(
savePath
,
targetPath
)
}
return
targetPath
,
func
()
{
println
(
"Golang Installed Successfully
\n
Installed v
ersion:"
,
version
)
println
(
"Golang Installed Successfully
V
ersion:"
,
version
)
}
}
return
""
,
nil
...
...
cmd/internal/install/install_nsis.go
浏览文件 @
7674c729
...
...
@@ -17,27 +17,15 @@ import (
"github.com/energye/energy/v2/cmd/internal/tools"
"path/filepath"
"runtime"
"strings"
)
func
installNSIS
(
c
*
command
.
Config
)
(
string
,
func
())
{
if
!
c
.
Install
.
INSIS
{
return
""
,
nil
}
if
consts
.
IsWindows
&&
runtime
.
GOARCH
==
"amd64"
{
if
tools
.
CommandExists
(
"makensis"
)
{
//if tools.IsExist(filepath.Join(os.Getenv(consts.NSISHomeKey), "makensis.exe")) {
println
(
"NSIS installed"
)
return
""
,
nil
}
print
(
"NSIS is not installed. Do you want to install NSIS? Y/n: "
)
var
s
string
if
strings
.
ToLower
(
c
.
Install
.
All
)
!=
"y"
{
fmt
.
Scanln
(
&
s
)
if
strings
.
ToLower
(
s
)
!=
"y"
{
println
(
"NSIS install exit"
)
return
""
,
nil
}
}
// 下载并安装配置NSIS
s
=
c
.
Install
.
Path
// 安装目录
s
:
=
c
.
Install
.
Path
// 安装目录
version
:=
consts
.
NSISDownloadVersion
fileName
:=
fmt
.
Sprintf
(
"nsis.windows.386-%s.zip"
,
version
)
downloadUrl
:=
fmt
.
Sprintf
(
consts
.
NSISDownloadURL
,
fileName
)
...
...
@@ -66,11 +54,9 @@ func installNSIS(c *command.Config) (string, func()) {
//zip
ExtractUnZip
(
savePath
,
targetPath
,
true
)
return
targetPath
,
func
()
{
println
(
"NSIS Installed Successfully
\n
Installed v
ersion:"
,
version
)
println
(
"NSIS Installed Successfully
V
ersion:"
,
version
)
}
}
}
else
{
println
(
"Non Windows amd64 skipping nsis"
)
}
return
""
,
nil
}
cmd/internal/progress-bar/bar.go
浏览文件 @
7674c729
...
...
@@ -49,7 +49,7 @@ func NewBar(totalVale int) *Bar {
totalValue
:
totalVale
,
currentValue
:
0
,
progressGraphTotal
:
defaultCount
,
progressGraph
:
"
█
"
,
progressGraph
:
"
=
"
,
backGraph
:
" "
,
progressEnds
:
Ends
{
Start
:
"["
,
End
:
"]"
},
isShowPercent
:
true
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录