Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
energye
energy
提交
119a288b
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,发现更多精彩内容 >>
提交
119a288b
编写于
8月 19, 2023
作者:
yanghye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
U: upgrade command-line tool
上级
1ae9468f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
41 addition
and
58 deletion
+41
-58
cmd/internal/install.go
cmd/internal/install.go
+41
-58
未找到文件。
cmd/internal/install.go
浏览文件 @
119a288b
...
...
@@ -79,34 +79,21 @@ const (
// https://cef-builds.spotifycdn.com/cef_binary_107.1.11%2Bg26c0b5e%2Bchromium-107.0.5304.110_windows64.tar.bz2
// 运行安装
func
runInstall
(
c
*
CommandConfig
)
error
{
//var (
// gtk int
//)
// if isLinux { // linux, gtk2, gtk3 install
// var gtksel = []string{"", "GTK3", "GTK2"}
// println(`
//Your current installation environment is Linux and there are two GTK solutions available, namely GTK2 GTK3
// GTK2: Supports LCL window and can use various LCL controls. The CEF<=106 version supports by default
// GTK3: does not support LCL windows and most LCL controls, CEF>=107 version default support
// Enter the number to select the installation support for different versions of GTK framework
// Number Description
// 1: GTK3
// 2: GTK2`)
// // 输入选择GTK支持框架
// for {
// print("Please enter the number: ")
// fmt.Scan(>k)
// if gtk == GTK3 || gtk == GTK2 {
// break
// } else {
// println("Number input error, please re-enter. Only 1: GTK3 or 2: GTK2 are supported")
// }
// }
// println("Support framework selected:", gtksel[gtk])
// }
// 获取提取文件配置
extractData
,
err
:=
httpRequestGET
(
DownloadExtractURL
)
if
err
!=
nil
{
fmt
.
Fprint
(
os
.
Stderr
,
err
.
Error
(),
"
\n
"
)
os
.
Exit
(
1
)
}
// 获取安装版本配置
downloadJSON
,
err
:=
httpRequestGET
(
DownloadVersionURL
)
if
err
!=
nil
{
fmt
.
Fprint
(
os
.
Stderr
,
err
.
Error
()
+
"
\n
"
)
os
.
Exit
(
1
)
}
// -c cef args value
//windows7, gtk2, flash
//
default(empty),
windows7, gtk2, flash
cef
:=
strings
.
ToLower
(
c
.
Install
.
CEF
)
//if cef != CefEmpty && cef != CefWin7 && cef != CefGtk2 && cef != CefFlash {
// fmt.Fprint(os.Stderr, "-c [cef] Incorrect args value\n")
...
...
@@ -114,11 +101,13 @@ func runInstall(c *CommandConfig) error {
//}
if
c
.
Install
.
Path
==
""
{
// current dir
c
.
Install
.
Path
=
c
.
Wd
}
installPathName
:=
filepath
.
Join
(
c
.
Install
.
Path
,
c
.
Install
.
Name
)
println
(
"Install Path"
,
installPathName
)
if
c
.
Install
.
Version
==
""
{
// latest
c
.
Install
.
Version
=
"latest"
}
// 创建安装目录
...
...
@@ -126,29 +115,24 @@ func runInstall(c *CommandConfig) error {
os
.
MkdirAll
(
installPathName
,
fs
.
ModePerm
)
os
.
MkdirAll
(
filepath
.
Join
(
c
.
Install
.
Path
,
frameworkCache
),
fs
.
ModePerm
)
println
(
"Start downloading CEF and Energy dependency"
)
// 获取安装版本配置
downloadJSON
,
err
:=
httpRequestGET
(
DownloadVersionURL
)
if
err
!=
nil
{
fmt
.
Fprint
(
os
.
Stderr
,
err
.
Error
()
+
"
\n
"
)
os
.
Exit
(
1
)
}
var
edv
map
[
string
]
interface
{}
downloadJSON
=
bytes
.
TrimPrefix
(
downloadJSON
,
[]
byte
(
"
\xef\xbb\xbf
"
))
if
err
:=
json
.
Unmarshal
(
downloadJSON
,
&
edv
);
err
!=
nil
{
fmt
.
Fprint
(
os
.
Stderr
,
err
.
Error
()
+
"
\n
"
)
os
.
Exit
(
1
)
}
// 拿到最新版本和版本列表
var
latest
=
edv
[
"latest"
]
.
(
string
)
// 所有版本列表
var
versionList
=
edv
[
"versionList"
]
.
(
map
[
string
]
interface
{})
// 安装版本
//
当前
安装版本
var
installVersion
map
[
string
]
interface
{}
if
c
.
Install
.
Version
==
"latest"
{
// 默认最新版本
if
v
,
ok
:=
versionList
[
latest
];
ok
{
if
c
.
Install
.
Version
==
"latest"
{
// 默认最新版本
if
v
,
ok
:=
versionList
[
edv
[
"latest"
]
.
(
string
)];
ok
{
installVersion
=
v
.
(
map
[
string
]
interface
{})
}
}
else
{
// 自己选择版本
}
else
{
// 自己选择版本
if
v
,
ok
:=
versionList
[
c
.
Install
.
Version
];
ok
{
installVersion
=
v
.
(
map
[
string
]
interface
{})
}
...
...
@@ -160,49 +144,54 @@ func runInstall(c *CommandConfig) error {
}
// 当前版本 cef 和 liblcl 版本选择
var
(
cefVersion
,
energyVersion
string
cefModule
,
energyModule
string
cefVersion
,
energyVersion
string
cefModule
Name
,
energyModuleName
string
)
// 使用提供的特定版本号
if
cef
==
CefGtk2
{
cefModule
=
"cef-106"
cefModule
Name
=
"cef-106"
// CEF 106.1.1
}
else
if
cef
==
CefWin7
{
cefModule
=
"cef-106"
cefModule
Name
=
"cef-109"
// CEF 109.1.18
}
else
if
cef
==
CefFlash
{
// cef 87 要和 liblcl 87 配对
cefModule
=
"cef-87"
energyModule
=
"liblcl-87"
cefModule
Name
=
"cef-87"
// CEF 87.1.14
energyModule
Name
=
"liblcl-87"
// liblcl 87
}
//
为空未指定CEF参数、或参数不正确,选择当前CEF模块最
大的版本号
if
cefModule
==
""
{
//
如未指定CEF参数、或参数不正确,选择当前CEF模块最(新)
大的版本号
if
cefModule
Name
==
""
{
var
cefDefault
string
var
number
int
for
module
,
_
:=
range
installVersion
{
if
strings
.
Index
(
module
,
"cef"
)
==
0
{
if
s
:=
strings
.
Split
(
module
,
"-"
);
len
(
s
)
==
2
{
// module = "cef-xxx"
n
,
_
:=
strconv
.
Atoi
(
s
[
1
])
if
n
>=
number
{
number
=
n
cefDefault
=
module
}
}
else
{
// module = "cef"
cefDefault
=
module
break
}
}
}
cefModule
=
cefDefault
cefModule
Name
=
cefDefault
}
// liblcl
if
energyModule
==
""
{
energyModule
=
"liblcl"
// liblcl
, 在未指定flash版本时,它是空 ""
if
energyModule
Name
==
""
{
energyModule
Name
=
"liblcl"
}
cefVersion
=
ToRNilString
(
installVersion
[
cefModule
],
""
)
energyVersion
=
ToRNilString
(
installVersion
[
energyModule
],
""
)
// 根据模块名拿到版本号
cefVersion
=
ToRNilString
(
installVersion
[
cefModuleName
],
""
)
energyVersion
=
ToRNilString
(
installVersion
[
energyModuleName
],
""
)
// 当前安装版本的所有模块
var
modules
map
[
string
]
any
if
m
,
ok
:=
installVersion
[
"modules"
];
ok
{
modules
=
m
.
(
map
[
string
]
any
)
}
// 根据模块名拿到对应的模块配置
fmt
.
Println
(
"log:"
,
modules
)
var
downloadURL
map
[
string
]
interface
{}
if
c
.
Install
.
Download
==
"gitee"
{
...
...
@@ -222,12 +211,6 @@ func runInstall(c *CommandConfig) error {
downloadEnergyURL
=
strings
.
ReplaceAll
(
downloadEnergyURL
,
"{version}"
,
energyVersion
)
downloadEnergyURL
=
strings
.
ReplaceAll
(
downloadEnergyURL
,
"{OSARCH}"
,
libEnergyOS
)
//提取文件配置
extractData
,
err
:=
httpRequestGET
(
DownloadExtractURL
)
if
err
!=
nil
{
fmt
.
Fprint
(
os
.
Stderr
,
err
.
Error
(),
"
\n
"
)
os
.
Exit
(
1
)
}
// 获取安装环境配置
var
extractConfig
map
[
string
]
interface
{}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录