Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
energye
energy
提交
e6c88e65
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 搜索 >>
提交
e6c88e65
编写于
9月 05, 2023
作者:
yanghye
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
energy-command-line, set env to path
上级
5d999084
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
97 addition
and
70 deletion
+97
-70
cmd/internal/consts/consts.go
cmd/internal/consts/consts.go
+2
-1
cmd/internal/env.go
cmd/internal/env.go
+2
-1
cmd/internal/env/env.go
cmd/internal/env/env.go
+14
-14
cmd/internal/install/install.go
cmd/internal/install/install.go
+2
-1
cmd/internal/install/install_cef_framework.go
cmd/internal/install/install_cef_framework.go
+38
-37
cmd/internal/install/install_golang.go
cmd/internal/install/install_golang.go
+5
-4
cmd/internal/install/install_nsis.go
cmd/internal/install/install_nsis.go
+8
-5
cmd/internal/install/install_upx.go
cmd/internal/install/install_upx.go
+17
-0
cmd/internal/project/project.go
cmd/internal/project/project.go
+2
-1
cmd/internal/tools/tools.go
cmd/internal/tools/tools.go
+5
-5
cmd/internal/version.go
cmd/internal/version.go
+2
-1
未找到文件。
cmd/internal/co
mmand
/consts.go
→
cmd/internal/co
nsts
/consts.go
浏览文件 @
e6c88e65
...
...
@@ -8,7 +8,7 @@
//
//----------------------------------------
package
co
mmand
package
co
nsts
import
"runtime"
...
...
@@ -39,6 +39,7 @@ const (
// https://gitee.com/energye/assets/releases/download/environment/nsis.windows.386-3.09.zip
NSISDownloadURL
=
"https://gitee.com/energye/assets/releases/download/environment/%s"
NSISDownloadVersion
=
"3.09"
NSISHomeKey
=
"NSIS_HOME"
)
const
(
...
...
cmd/internal/env.go
浏览文件 @
e6c88e65
...
...
@@ -12,6 +12,7 @@ package internal
import
(
"github.com/energye/energy/v2/cmd/internal/command"
"github.com/energye/energy/v2/cmd/internal/consts"
"os"
)
...
...
@@ -29,7 +30,7 @@ func init() {
}
func
runGetEnv
(
c
*
command
.
Config
)
error
{
envPath
:=
os
.
Getenv
(
co
mmand
.
EnergyHomeKey
)
envPath
:=
os
.
Getenv
(
co
nsts
.
EnergyHomeKey
)
println
(
"ENERGY_HOME_KEY"
,
envPath
)
return
nil
}
cmd/internal/env/env.go
浏览文件 @
e6c88e65
...
...
@@ -13,7 +13,7 @@ package env
import
(
"bytes"
"fmt"
"github.com/energye/energy/v2/cmd/internal/co
mmand
"
"github.com/energye/energy/v2/cmd/internal/co
nsts
"
"github.com/energye/energy/v2/cmd/internal/tools"
"github.com/energye/golcl/energy/homedir"
toolsCommand
"github.com/energye/golcl/tools/command"
...
...
@@ -31,7 +31,7 @@ type envToPath struct {
}
func
init
()
{
if
co
mmand
.
IsWindows
{
if
co
nsts
.
IsWindows
{
envPath
=
&
envToPath
{}
}
}
...
...
@@ -83,15 +83,15 @@ func SetNSISEnv(nsisRoot string) {
}
}
defer
cmd
.
Close
()
var
args
=
[]
string
{
"NSIS_HOME"
,
nsisRoot
}
var
args
=
[]
string
{
consts
.
NSISHomeKey
,
nsisRoot
}
cmd
.
Command
(
"setx"
,
args
...
)
envPath
.
add
(
"%NSIS_HOME%"
)
//
envPath.add("%NSIS_HOME%")
println
(
"
\n
Hint: Reopen the cmd window for the makensis command to take effect."
)
}
func
SetGoEnv
(
goRoot
string
)
{
var
goexe
=
"go"
if
co
mmand
.
IsWindows
{
if
co
nsts
.
IsWindows
{
goexe
+=
".exe"
}
gobin
:=
filepath
.
Join
(
goRoot
,
"bin"
,
goexe
)
...
...
@@ -112,7 +112,7 @@ func SetGoEnv(goRoot string) {
}
}
defer
cmd
.
Close
()
if
co
mmand
.
IsWindows
{
if
co
nsts
.
IsWindows
{
// setx
// GOROOT=/to/go/path
var
args
=
[]
string
{
"GOROOT"
,
goRoot
}
...
...
@@ -142,11 +142,11 @@ func SetGoEnv(goRoot string) {
func
SetEnergyHomeEnv
(
homePath
string
)
{
var
cef
string
if
co
mmand
.
IsWindows
{
if
co
nsts
.
IsWindows
{
cef
=
"libcef.dll"
}
else
if
co
mmand
.
IsLinux
{
}
else
if
co
nsts
.
IsLinux
{
cef
=
"libcef.so"
}
else
if
co
mmand
.
IsDarwin
{
}
else
if
co
nsts
.
IsDarwin
{
cef
=
"cef_sandbox.a"
}
cefPath
:=
filepath
.
Join
(
homePath
,
cef
)
...
...
@@ -167,11 +167,11 @@ func SetEnergyHomeEnv(homePath string) {
}
}
defer
cmd
.
Close
()
if
co
mmand
.
IsWindows
{
var
args
=
[]
string
{
"/c"
,
"setx"
,
co
mmand
.
EnergyHomeKey
,
homePath
}
if
co
nsts
.
IsWindows
{
var
args
=
[]
string
{
"/c"
,
"setx"
,
co
nsts
.
EnergyHomeKey
,
homePath
}
cmd
.
Command
(
"cmd.exe"
,
args
...
)
}
else
{
var
energyHome
=
fmt
.
Sprintf
(
"export %s=%s"
,
co
mmand
.
EnergyHomeKey
,
homePath
)
var
energyHome
=
fmt
.
Sprintf
(
"export %s=%s"
,
co
nsts
.
EnergyHomeKey
,
homePath
)
exs
:=
[]
string
{
energyHome
}
setPosixEnv
(
exs
,
""
,
""
)
}
...
...
@@ -192,9 +192,9 @@ func setPosixEnv(exs []string, binPath, bin string) {
}
defer
cmd
.
Close
()
var
envFiles
[]
string
if
co
mmand
.
IsLinux
{
if
co
nsts
.
IsLinux
{
envFiles
=
[]
string
{
".profile"
,
".zshrc"
,
".bashrc"
}
}
else
if
co
mmand
.
IsDarwin
{
}
else
if
co
nsts
.
IsDarwin
{
envFiles
=
[]
string
{
".profile"
,
".zshrc"
,
".bash_profile"
}
}
homeDir
,
err
:=
homedir
.
Dir
()
...
...
cmd/internal/install/install.go
浏览文件 @
e6c88e65
...
...
@@ -16,6 +16,7 @@ import (
"compress/gzip"
"fmt"
"github.com/energye/energy/v2/cmd/internal/command"
"github.com/energye/energy/v2/cmd/internal/consts"
"github.com/energye/energy/v2/cmd/internal/env"
progressbar
"github.com/energye/energy/v2/cmd/internal/progress-bar"
"github.com/energye/energy/v2/cmd/internal/tools"
...
...
@@ -93,7 +94,7 @@ func initInstall(c *command.Config) {
os
.
MkdirAll
(
cefInstallPathName
(
c
),
fs
.
ModePerm
)
os
.
MkdirAll
(
goInstallPathName
(
c
),
fs
.
ModePerm
)
os
.
MkdirAll
(
nsisInstallPathName
(
c
),
fs
.
ModePerm
)
os
.
MkdirAll
(
filepath
.
Join
(
c
.
Install
.
Path
,
co
mmand
.
FrameworkCache
),
fs
.
ModePerm
)
os
.
MkdirAll
(
filepath
.
Join
(
c
.
Install
.
Path
,
co
nsts
.
FrameworkCache
),
fs
.
ModePerm
)
}
func
filePathInclude
(
compressPath
string
,
files
...
any
)
(
string
,
bool
)
{
...
...
cmd/internal/install/install_cef_framework.go
浏览文件 @
e6c88e65
...
...
@@ -14,6 +14,7 @@ import (
"encoding/json"
"fmt"
"github.com/energye/energy/v2/cmd/internal/command"
"github.com/energye/energy/v2/cmd/internal/consts"
progressbar
"github.com/energye/energy/v2/cmd/internal/progress-bar"
"github.com/energye/energy/v2/cmd/internal/tools"
"net/url"
...
...
@@ -39,7 +40,7 @@ func installCEFFramework(c *command.Config) string {
}
}
// 获取提取文件配置
extractData
,
err
:=
tools
.
HttpRequestGET
(
co
mmand
.
DownloadExtractURL
)
extractData
,
err
:=
tools
.
HttpRequestGET
(
co
nsts
.
DownloadExtractURL
)
if
err
!=
nil
{
fmt
.
Println
(
"Error:"
,
err
.
Error
())
os
.
Exit
(
1
)
...
...
@@ -55,7 +56,7 @@ func installCEFFramework(c *command.Config) string {
extractOSConfig
:=
extractConfig
[
runtime
.
GOOS
]
.
(
map
[
string
]
any
)
// 获取安装版本配置
downloadJSON
,
err
:=
tools
.
HttpRequestGET
(
co
mmand
.
DownloadVersionURL
)
downloadJSON
,
err
:=
tools
.
HttpRequestGET
(
co
nsts
.
DownloadVersionURL
)
if
err
!=
nil
{
fmt
.
Println
(
"Error:"
,
err
.
Error
())
os
.
Exit
(
1
)
...
...
@@ -72,7 +73,7 @@ func installCEFFramework(c *command.Config) string {
// -c cef args value
// default(empty), windows7, gtk2, flash
cef
:=
strings
.
ToLower
(
c
.
Install
.
CEF
)
if
cef
!=
co
mmand
.
CefEmpty
&&
cef
!=
command
.
Cef109
&&
cef
!=
command
.
Cef106
&&
cef
!=
command
.
Cef87
{
if
cef
!=
co
nsts
.
CefEmpty
&&
cef
!=
consts
.
Cef109
&&
cef
!=
consts
.
Cef106
&&
cef
!=
consts
.
Cef87
{
fmt
.
Println
(
"Error:"
,
"-c [cef] Incorrect args value"
)
os
.
Exit
(
1
)
return
""
...
...
@@ -108,11 +109,11 @@ func installCEFFramework(c *command.Config) string {
cefModuleName
,
liblclModuleName
string
)
// 使用提供的特定版本号
if
cef
==
co
mmand
.
Cef106
{
if
cef
==
co
nsts
.
Cef106
{
cefModuleName
=
"cef-106"
// CEF 106.1.1
}
else
if
cef
==
co
mmand
.
Cef109
{
}
else
if
cef
==
co
nsts
.
Cef109
{
cefModuleName
=
"cef-109"
// CEF 109.1.18
}
else
if
cef
==
co
mmand
.
Cef87
{
}
else
if
cef
==
co
nsts
.
Cef87
{
// cef 87 要和 liblcl 87 配对
cefModuleName
=
"cef-87"
// CEF 87.1.14
liblclModuleName
=
"liblcl-87"
// liblcl 87
...
...
@@ -185,7 +186,7 @@ func installCEFFramework(c *command.Config) string {
downloadCefURL
=
replaceSource
(
downloadCefURL
,
tools
.
ToString
(
cefModule
[
"downloadSource"
]),
tools
.
ToInt
(
cefModule
[
"downloadSourceSelect"
]),
"cef"
)
downloadCefURL
=
strings
.
ReplaceAll
(
downloadCefURL
,
"{version}"
,
cefVersion
)
downloadCefURL
=
strings
.
ReplaceAll
(
downloadCefURL
,
"{OSARCH}"
,
libCEFOS
)
downloads
[
co
mmand
.
CefKey
]
=
&
downloadInfo
{
isSupport
:
isSupport
,
fileName
:
urlName
(
downloadCefURL
),
downloadPath
:
filepath
.
Join
(
c
.
Install
.
Path
,
command
.
FrameworkCache
,
urlName
(
downloadCefURL
)),
frameworkPath
:
installPathName
,
url
:
downloadCefURL
,
module
:
cefModuleName
}
downloads
[
co
nsts
.
CefKey
]
=
&
downloadInfo
{
isSupport
:
isSupport
,
fileName
:
urlName
(
downloadCefURL
),
downloadPath
:
filepath
.
Join
(
c
.
Install
.
Path
,
consts
.
FrameworkCache
,
urlName
(
downloadCefURL
)),
frameworkPath
:
installPathName
,
url
:
downloadCefURL
,
module
:
cefModuleName
}
// liblcl
// 如果选定的cef 106,在linux会指定liblcl gtk2 版本, 其它系统和版本以默认的形式区分
...
...
@@ -199,7 +200,7 @@ func installCEFFramework(c *command.Config) string {
downloadEnergyURL
=
strings
.
ReplaceAll
(
downloadEnergyURL
,
"{version}"
,
liblclVersion
)
downloadEnergyURL
=
strings
.
ReplaceAll
(
downloadEnergyURL
,
"{module}"
,
module
)
downloadEnergyURL
=
strings
.
ReplaceAll
(
downloadEnergyURL
,
"{OSARCH}"
,
libEnergyOS
)
downloads
[
co
mmand
.
LiblclKey
]
=
&
downloadInfo
{
isSupport
:
isSupport
,
fileName
:
urlName
(
downloadEnergyURL
),
downloadPath
:
filepath
.
Join
(
c
.
Install
.
Path
,
command
.
FrameworkCache
,
urlName
(
downloadEnergyURL
)),
frameworkPath
:
installPathName
,
url
:
downloadEnergyURL
,
module
:
liblclModuleName
}
downloads
[
co
nsts
.
LiblclKey
]
=
&
downloadInfo
{
isSupport
:
isSupport
,
fileName
:
urlName
(
downloadEnergyURL
),
downloadPath
:
filepath
.
Join
(
c
.
Install
.
Path
,
consts
.
FrameworkCache
,
urlName
(
downloadEnergyURL
)),
frameworkPath
:
installPathName
,
url
:
downloadEnergyURL
,
module
:
liblclModuleName
}
}
// 在线下载框架二进制包
...
...
@@ -230,7 +231,7 @@ func installCEFFramework(c *command.Config) string {
continue
}
if
di
.
success
{
if
key
==
co
mmand
.
CefKey
{
if
key
==
co
nsts
.
CefKey
{
bar
:=
progressbar
.
NewBar
(
0
)
bar
.
SetNotice
(
"Unpack file "
+
key
+
": "
)
tarName
:=
UnBz2ToTar
(
di
.
downloadPath
,
func
(
totalLength
,
processLength
int64
)
{
...
...
@@ -238,7 +239,7 @@ func installCEFFramework(c *command.Config) string {
})
bar
.
PrintEnd
()
ExtractFiles
(
key
,
tarName
,
di
,
extractOSConfig
)
}
else
if
key
==
co
mmand
.
LiblclKey
{
}
else
if
key
==
co
nsts
.
LiblclKey
{
ExtractFiles
(
key
,
di
.
downloadPath
,
di
,
extractOSConfig
)
}
println
(
"Unpack file"
,
key
,
"success
\n
"
)
...
...
@@ -263,49 +264,49 @@ func cefOS(module map[string]any) (string, bool) {
}
return
false
}
if
co
mmand
.
IsWindows
{
// windows arm for 64 bit, windows for 32/64 bit
if
co
nsts
.
IsWindows
{
// windows arm for 64 bit, windows for 32/64 bit
if
runtime
.
GOARCH
==
"arm64"
{
return
"windowsarm64"
,
isSupport
(
co
mmand
.
WindowsARM64
)
return
"windowsarm64"
,
isSupport
(
co
nsts
.
WindowsARM64
)
}
if
strconv
.
IntSize
==
32
{
return
fmt
.
Sprintf
(
"windows%d"
,
strconv
.
IntSize
),
isSupport
(
co
mmand
.
Windows32
)
return
fmt
.
Sprintf
(
"windows%d"
,
strconv
.
IntSize
),
isSupport
(
co
nsts
.
Windows32
)
}
return
fmt
.
Sprintf
(
"windows%d"
,
strconv
.
IntSize
),
isSupport
(
co
mmand
.
Windows64
)
}
else
if
co
mmand
.
IsLinux
{
//linux for 64 bit
return
fmt
.
Sprintf
(
"windows%d"
,
strconv
.
IntSize
),
isSupport
(
co
nsts
.
Windows64
)
}
else
if
co
nsts
.
IsLinux
{
//linux for 64 bit
if
runtime
.
GOARCH
==
"arm64"
{
if
mod
==
co
mmand
.
Cef106
{
return
"linuxarm64"
,
isSupport
(
co
mmand
.
LinuxARM64GTK2
)
if
mod
==
co
nsts
.
Cef106
{
return
"linuxarm64"
,
isSupport
(
co
nsts
.
LinuxARM64GTK2
)
}
return
"linuxarm64"
,
isSupport
(
co
mmand
.
LinuxARM64
)
||
isSupport
(
command
.
LinuxARM64GTK3
)
return
"linuxarm64"
,
isSupport
(
co
nsts
.
LinuxARM64
)
||
isSupport
(
consts
.
LinuxARM64GTK3
)
}
else
if
runtime
.
GOARCH
==
"amd64"
{
if
mod
==
co
mmand
.
Cef106
{
return
"linux64"
,
isSupport
(
co
mmand
.
Linux64GTK2
)
if
mod
==
co
nsts
.
Cef106
{
return
"linux64"
,
isSupport
(
co
nsts
.
Linux64GTK2
)
}
return
"linux64"
,
isSupport
(
co
mmand
.
Linux64
)
||
isSupport
(
command
.
Linux64GTK3
)
return
"linux64"
,
isSupport
(
co
nsts
.
Linux64
)
||
isSupport
(
consts
.
Linux64GTK3
)
}
}
else
if
co
mmand
.
IsDarwin
{
// macosx for 64 bit
}
else
if
co
nsts
.
IsDarwin
{
// macosx for 64 bit
//if runtime.GOARCH == "arm64" {
// return "macosarm64", isSupport(MacOSARM64)
//} else if runtime.GOARCH == "amd64" {
// return "macosx64", isSupport(MacOSX64)
//}
// Mac amd64 m1 m2 架构目前使用amd64, m1,m2使用Rosetta2兼容
return
"macosx64"
,
isSupport
(
co
mmand
.
MacOSX64
)
return
"macosx64"
,
isSupport
(
co
nsts
.
MacOSX64
)
}
//not support
return
fmt
.
Sprintf
(
"%v %v"
,
runtime
.
GOOS
,
runtime
.
GOARCH
),
false
}
var
liblclFileNames
=
map
[
string
]
string
{
"windows32"
:
co
mmand
.
Windows32
,
"windows64"
:
co
mmand
.
Windows64
,
"windowsarm64"
:
co
mmand
.
WindowsARM64
,
"linuxarm64"
:
co
mmand
.
LinuxARM64
,
"linuxarm64gtk2"
:
co
mmand
.
LinuxARM64GTK2
,
"linux64"
:
co
mmand
.
Linux64
,
"linux64gtk2"
:
co
mmand
.
Linux64GTK2
,
"darwin64"
:
co
mmand
.
MacOSX64
,
"darwinarm64"
:
co
mmand
.
MacOSARM64
,
"windows32"
:
co
nsts
.
Windows32
,
"windows64"
:
co
nsts
.
Windows64
,
"windowsarm64"
:
co
nsts
.
WindowsARM64
,
"linuxarm64"
:
co
nsts
.
LinuxARM64
,
"linuxarm64gtk2"
:
co
nsts
.
LinuxARM64GTK2
,
"linux64"
:
co
nsts
.
Linux64
,
"linux64gtk2"
:
co
nsts
.
Linux64GTK2
,
"darwin64"
:
co
nsts
.
MacOSX64
,
"darwinarm64"
:
co
nsts
.
MacOSARM64
,
"windows32_old"
:
"Windows 32 bits"
,
"windows64_old"
:
"Windows 64 bits"
,
"linux64gtk2_old"
:
"Linux GTK2 x86 64 bits"
,
...
...
@@ -317,10 +318,10 @@ func liblclName(version, cef string) (string, bool) {
var
key
string
var
isOld
bool
if
runtime
.
GOARCH
==
"arm64"
{
if
co
mmand
.
IsLinux
&&
cef
==
command
.
Cef106
{
// 只linux区别liblcl gtk2
if
co
nsts
.
IsLinux
&&
cef
==
consts
.
Cef106
{
// 只linux区别liblcl gtk2
key
=
"linuxarm64gtk2"
}
else
{
if
co
mmand
.
IsDarwin
{
if
co
nsts
.
IsDarwin
{
// Mac amd64 m1 m2 架构目前使用amd64, m1,m2使用Rosetta2兼容
key
=
fmt
.
Sprintf
(
"%samd64"
,
runtime
.
GOOS
)
}
else
{
...
...
@@ -328,7 +329,7 @@ func liblclName(version, cef string) (string, bool) {
}
}
}
else
if
runtime
.
GOARCH
==
"amd64"
{
if
co
mmand
.
IsLinux
&&
cef
==
command
.
Cef106
{
// 只linux区别liblcl gtk2
if
co
nsts
.
IsLinux
&&
cef
==
consts
.
Cef106
{
// 只linux区别liblcl gtk2
key
=
"linux64gtk2"
}
else
{
key
=
fmt
.
Sprintf
(
"%s%d"
,
runtime
.
GOOS
,
strconv
.
IntSize
)
...
...
@@ -374,10 +375,10 @@ func liblclOS(cef, version, buildSupportOSArch string) (string, bool) {
func
ExtractFiles
(
keyName
,
sourcePath
string
,
di
*
downloadInfo
,
extractOSConfig
map
[
string
]
any
)
{
println
(
"Extract"
,
keyName
,
"sourcePath:"
,
sourcePath
,
"targetPath:"
,
di
.
frameworkPath
)
files
:=
extractOSConfig
[
keyName
]
.
([]
any
)
if
keyName
==
co
mmand
.
CefKey
{
if
keyName
==
co
nsts
.
CefKey
{
//tar
ExtractUnTar
(
sourcePath
,
di
.
frameworkPath
,
files
...
)
}
else
if
keyName
==
co
mmand
.
LiblclKey
{
}
else
if
keyName
==
co
nsts
.
LiblclKey
{
//zip
ExtractUnZip
(
sourcePath
,
di
.
frameworkPath
,
false
,
files
...
)
}
...
...
cmd/internal/install/install_golang.go
浏览文件 @
e6c88e65
...
...
@@ -12,6 +12,7 @@ package install
import
(
"fmt"
"github.com/energye/energy/v2/cmd/internal/command"
"github.com/energye/energy/v2/cmd/internal/consts"
progressbar
"github.com/energye/energy/v2/cmd/internal/progress-bar"
"github.com/energye/energy/v2/cmd/internal/tools"
"io/fs"
...
...
@@ -43,7 +44,7 @@ func installGolang(c *command.Config) string {
"windows"
:
"zip"
,
}
// 开始下载并安装Go开发环境
version
:=
co
mmand
.
GolangDefaultVersion
version
:=
co
nsts
.
GolangDefaultVersion
gos
:=
runtime
.
GOOS
arch
:=
runtime
.
GOARCH
ext
:=
exts
[
gos
]
...
...
@@ -55,8 +56,8 @@ func installGolang(c *command.Config) string {
}
}
fileName
:=
fmt
.
Sprintf
(
"go%s.%s-%s.%s"
,
version
,
gos
,
arch
,
ext
)
downloadUrl
:=
fmt
.
Sprintf
(
co
mmand
.
GolangDownloadURL
,
fileName
)
savePath
:=
filepath
.
Join
(
s
,
co
mmand
.
FrameworkCache
,
fileName
)
downloadUrl
:=
fmt
.
Sprintf
(
co
nsts
.
GolangDownloadURL
,
fileName
)
savePath
:=
filepath
.
Join
(
s
,
co
nsts
.
FrameworkCache
,
fileName
)
var
err
error
println
(
"Golang Download URL:"
,
downloadUrl
)
println
(
"Golang Save Path:"
,
savePath
)
...
...
@@ -78,7 +79,7 @@ func installGolang(c *command.Config) string {
// 使用 go 名字做为 go 安装目录
targetPath
:=
filepath
.
Join
(
s
,
"go"
)
// 释放文件
if
co
mmand
.
IsWindows
{
if
co
nsts
.
IsWindows
{
//zip
ExtractUnZip
(
savePath
,
targetPath
,
true
)
}
else
{
...
...
cmd/internal/install/install_nsis.go
浏览文件 @
e6c88e65
...
...
@@ -12,16 +12,19 @@ package install
import
(
"fmt"
"github.com/energye/energy/v2/cmd/internal/command"
"github.com/energye/energy/v2/cmd/internal/consts"
progressbar
"github.com/energye/energy/v2/cmd/internal/progress-bar"
"github.com/energye/energy/v2/cmd/internal/tools"
"os"
"path/filepath"
"runtime"
"strings"
)
func
installNSIS
(
c
*
command
.
Config
)
string
{
if
command
.
IsWindows
&&
runtime
.
GOARCH
==
"amd64"
{
if
tools
.
CommandExists
(
"makensis"
)
{
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
""
}
...
...
@@ -36,9 +39,9 @@ func installNSIS(c *command.Config) string {
}
// 下载并安装配置NSIS
s
=
c
.
Install
.
Path
// 安装目录
fileName
:=
fmt
.
Sprintf
(
"nsis.windows.386-%s.zip"
,
co
mmand
.
NSISDownloadVersion
)
downloadUrl
:=
fmt
.
Sprintf
(
co
mmand
.
NSISDownloadURL
,
fileName
)
savePath
:=
filepath
.
Join
(
s
,
co
mmand
.
FrameworkCache
,
fileName
)
fileName
:=
fmt
.
Sprintf
(
"nsis.windows.386-%s.zip"
,
co
nsts
.
NSISDownloadVersion
)
downloadUrl
:=
fmt
.
Sprintf
(
co
nsts
.
NSISDownloadURL
,
fileName
)
savePath
:=
filepath
.
Join
(
s
,
co
nsts
.
FrameworkCache
,
fileName
)
var
err
error
println
(
"Golang Download URL:"
,
downloadUrl
)
println
(
"Golang Save Path:"
,
savePath
)
...
...
cmd/internal/install/install_upx.go
0 → 100644
浏览文件 @
e6c88e65
//----------------------------------------
//
// Copyright © yanghy. All Rights Reserved.
//
// Licensed under Apache License Version 2.0, January 2004
//
// https://www.apache.org/licenses/LICENSE-2.0
//
//----------------------------------------
package
install
import
"github.com/energye/energy/v2/cmd/internal/command"
func
installUPX
(
c
*
command
.
Config
)
string
{
return
""
}
cmd/internal/project/project.go
浏览文件 @
e6c88e65
...
...
@@ -12,6 +12,7 @@ package project
import
(
"encoding/json"
"github.com/energye/energy/v2/cmd/internal/consts"
"github.com/energye/golcl/energy/tools"
"os"
"path/filepath"
...
...
@@ -38,7 +39,7 @@ func (m *Project) setDefaults() {
m
.
ProjectPath
,
_
=
os
.
Getwd
()
}
if
m
.
FrameworkPath
==
""
{
m
.
FrameworkPath
=
os
.
Getenv
(
"ENERGY_HOME"
)
m
.
FrameworkPath
=
os
.
Getenv
(
consts
.
EnergyHomeKey
)
}
if
!
tools
.
IsExist
(
m
.
FrameworkPath
)
{
panic
(
"energy framework directory does not exist: "
+
m
.
FrameworkPath
)
...
...
cmd/internal/tools/tools.go
浏览文件 @
e6c88e65
...
...
@@ -12,7 +12,7 @@ package tools
import
(
"bytes"
"github.com/energye/energy/v2/cmd/internal/co
mmand
"
"github.com/energye/energy/v2/cmd/internal/co
nsts
"
"github.com/energye/golcl/energy/tools"
"io/ioutil"
"math"
...
...
@@ -164,17 +164,17 @@ func Compare(compare1, compare2 string) bool {
func
CheckCEFDir
()
bool
{
var
lib
=
func
()
string
{
if
co
mmand
.
IsWindows
{
if
co
nsts
.
IsWindows
{
return
"libcef.dll"
}
else
if
co
mmand
.
IsLinux
{
}
else
if
co
nsts
.
IsLinux
{
return
"libcef.so"
}
else
if
co
mmand
.
IsDarwin
{
}
else
if
co
nsts
.
IsDarwin
{
return
"cef_sandbox.a"
}
return
""
}()
if
lib
!=
""
{
return
tools
.
IsExist
(
filepath
.
Join
(
os
.
Getenv
(
"ENERGY_HOME"
),
lib
))
return
tools
.
IsExist
(
filepath
.
Join
(
os
.
Getenv
(
consts
.
EnergyHomeKey
),
lib
))
}
return
false
}
cmd/internal/version.go
浏览文件 @
e6c88e65
...
...
@@ -15,6 +15,7 @@ import (
"encoding/json"
"fmt"
"github.com/energye/energy/v2/cmd/internal/command"
"github.com/energye/energy/v2/cmd/internal/consts"
"github.com/energye/energy/v2/cmd/internal/tools"
"os"
"sort"
...
...
@@ -35,7 +36,7 @@ func init() {
}
func
runVersion
(
c
*
command
.
Config
)
error
{
downloadJSON
,
err
:=
tools
.
HttpRequestGET
(
co
mmand
.
DownloadVersionURL
)
downloadJSON
,
err
:=
tools
.
HttpRequestGET
(
co
nsts
.
DownloadVersionURL
)
if
err
!=
nil
{
fmt
.
Fprint
(
os
.
Stderr
,
err
.
Error
()
+
"
\n
"
)
os
.
Exit
(
1
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录