1
0
forked from x/icebergs

opt mirrors.go

This commit is contained in:
IT 老营长 @云轩领航-创始人 2023-12-01 12:05:26 +08:00
parent 3fef266c10
commit 37cab25dc0
13 changed files with 52 additions and 30 deletions

View File

@ -17,8 +17,6 @@ const (
ADD = "add"
OSID = "osid"
REPOS = "repos"
UBUNTU = "ubuntu"
CENTOS = "centos"
ALPINE = "alpine"
BUSYBOX = "busybox"
RELEASE = "release"
@ -110,12 +108,9 @@ func insert(m *ice.Message, sys, cmd string, arg ...string) bool {
func IsAlpine(m *ice.Message, arg ...string) bool {
return insert(m, ALPINE, "system apk add", arg...)
}
func IsCentos(m *ice.Message, arg ...string) bool {
return insert(m, CENTOS, "system yum install -y", arg...)
}
func IsUbuntu(m *ice.Message, arg ...string) bool {
return insert(m, UBUNTU, "system apt get -y", arg...)
func IsRedhat(m *ice.Message, arg ...string) bool {
return insert(m, "rhel", "system yum install -y", arg...)
}
func IsSystem(m *ice.Message, arg ...string) bool {
return IsAlpine(m, arg...) || IsCentos(m, arg...) || IsUbuntu(m, arg...)
return IsAlpine(m, arg...) || IsRedhat(m, arg...)
}

View File

@ -149,7 +149,7 @@ func ToastProcess(m *ice.Message, arg ...ice.Any) func() {
Toast(m, toastContent(m, ice.PROCESS), arg...)
return func() { Toast(m, toastContent(m, ice.SUCCESS)) }
}
func GoToast(m *ice.Message, title string, cb func(toast func(string, int, int)) []string) *ice.Message {
func GoToast(m *ice.Message, title string, cb func(toast func(name string, count, total int)) []string) *ice.Message {
_total := 0
toast := func(name string, count, total int) {
kit.If(total == 0, func() { total = 1 })

View File

@ -124,7 +124,7 @@ func RenderMain(m *ice.Message) *ice.Message {
if m.IsCliUA() {
return m.RenderDownload(path.Join(ice.USR_INTSHELL, ice.INDEX_SH))
}
m.Options(nfs.SCRIPT, ice.SRC_MAIN_JS, nfs.VERSION, RenderVersion(m)+kit.Select("", "&pod="+m.Option(ice.MSG_USERPOD), m.Option(ice.MSG_USERPOD) != ""))
m.Options(nfs.SCRIPT, kit.MergeURL(ice.SRC_MAIN_JS, kit.Dict(nfs.VERSION, RenderVersion(m), ice.POD, m.Option(ice.MSG_USERPOD))))
return m.RenderResult(kit.Renders(m.Cmdx(nfs.CAT, ice.SRC_MAIN_HTML), m))
}
func RenderCmds(m *ice.Message, cmds ...ice.Any) {

View File

@ -398,7 +398,7 @@ func SpidePost(m *ice.Message, arg ...ice.Any) ice.Any {
func SpideDelete(m *ice.Message, arg ...ice.Any) ice.Any {
return kit.UnMarshal(m.Cmdx(http.MethodDelete, arg))
}
func SpideSave(m *ice.Message, file, link string, cb func(count int, total int, value int)) *ice.Message {
func SpideSave(m *ice.Message, file, link string, cb func(count, total, value int)) *ice.Message {
return m.Cmd(Prefix(SPIDE), ice.DEV, SPIDE_SAVE, file, http.MethodGet, link, cb)
}
func SpideOrigin(m *ice.Message, name string) string {

View File

@ -5,6 +5,7 @@ import (
"strings"
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/lex"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
@ -41,6 +42,7 @@ func init() {
line = strings.ReplaceAll(line, "%3a", ":")
kit.IfNoKey(host, kit.ParseURL(line).Host, func(p string) { list = append(list, line) })
}).Cmd(nfs.SAVE, kit.HomePath(FILE), strings.Join(list, lex.NL)+lex.NL)
m.Cmd(cli.SYSTEM, "git", "config", "--global", "credential.helper", "store")
m.ProcessClose()
}},
}, StatsAction(), mdb.HashAction(mdb.SHORT, mdb.UNIQ, mdb.FIELD, "time,hash,type,name,text", mdb.EXPIRE, mdb.MONTH)), Hand: func(m *ice.Message, arg ...string) {

View File

@ -5,20 +5,23 @@ import (
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/ctx"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
)
func _py_exec(m *ice.Message, p string) {
if _, e := nfs.DiskFile.StatFile(p); e == nil {
m.Cmdy(cli.SYSTEM, PYTHON, p)
m.Cmdy(cli.SYSTEM, mdb.Config(m, cli.CLI), p)
} else if b, e := nfs.ReadFile(m, p); e == nil {
m.Cmdy(cli.SYSTEM, PYTHON, "-c", string(b))
m.Cmdy(cli.SYSTEM, mdb.Config(m, cli.CLI), "-c", string(b))
}
}
const (
PYTHON = "python"
PYTHON2 = "python2"
PYTHON3 = "python3"
)
const PY = nfs.PY
@ -26,12 +29,17 @@ func init() {
Index.MergeCommands(ice.Commands{
PY: {Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
mdb.Config(m, cli.CLI, PYTHON)
cli.IsAlpine(m, PYTHON, "python3")
cli.IsCentos(m, PYTHON, "python2")
if cli.IsRedhat(m, PYTHON2, "python2") {
mdb.Config(m, cli.CLI, PYTHON2)
}
}},
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
ProcessXterm(m, mdb.Config(m, cli.CLI)+" -i "+path.Join(arg[2], arg[1]), "")
}},
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { ProcessXterm(m, PYTHON+" -i "+path.Join(arg[2], arg[1]), "") }},
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _py_exec(m, path.Join(arg[2], arg[1])) }},
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(nfs.Template(m, DEMO_PY)) }},
}, PlugAction())},
}, PlugAction(), ctx.ConfAction(cli.CLI))},
})
}

View File

@ -46,13 +46,18 @@ func init() {
uri = kit.MergeURL2(os.Getenv(cli.CTX_DEV), web.CHAT_POD+p, cli.GOOS, runtime.GOOS, cli.GOARCH, runtime.GOARCH)
})
dir := path.Join(kit.Format(value[nfs.PATH]), kit.Format(value[nfs.FILE]))
switch web.SpideSave(m, dir, uri, nil); value[mdb.TYPE] {
web.GoToast(m, m.PrefixKey(), func(toast func(name string, count, total int)) []string {
switch web.SpideSave(m, dir, uri, func(count, total, value int) {
toast(dir, count, total)
}); value[mdb.TYPE] {
case nfs.TAR:
m.Cmd(cli.SYSTEM, nfs.TAR, "xf", dir, "-C", path.Dir(dir))
// m.Cmd(nfs.TAR, mdb.EXPORT, dir, "-C", path.Dir(dir))
case ice.BIN:
os.Chmod(dir, ice.MOD_DIR)
}
return nil
})
m.Cmdy(nfs.DIR, dir, "time,size,path,hash")
})
if web.ToastSuccess(m); m.Option(ice.EXIT) == ice.TRUE {

View File

@ -97,7 +97,7 @@ func init() {
}), Hand: func(m *ice.Message, arg ...string) {
if kit.Ext(arg[0]) == "md" {
_spark_md(m, arg...)
} else if arg[0] == SHELL && kit.IsIn(kit.Select("", arg, 1), cli.ALPINE, cli.CENTOS, cli.LINUX, cli.DARWIN, cli.MACOS, cli.WINDOWS) {
} else if arg[0] == SHELL && kit.IsIn(kit.Select("", arg, 1), cli.ALPINE, "centos", cli.LINUX, cli.DARWIN, cli.MACOS, cli.WINDOWS) {
_spark_tabs(m, arg...)
} else {
if arg = _name(m, arg); arg[0] == SHELL && len(arg) > 3 && arg[2] == "with" && arg[3] == cli.ECHO {

View File

@ -13,6 +13,9 @@ const CLIENT = "client"
func init() {
Index.MergeCommands(ice.Commands{
CLIENT: {Help: "代码库", Actions: ice.MergeActions(ice.Actions{
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
cli.IsRedhat(m, GIT, "git")
}},
cli.ORDER: {Hand: func(m *ice.Message, arg ...string) {
m.Cmd(code.INSTALL, cli.ORDER, mdb.Config(m, nfs.SOURCE), "_install/bin")
m.Cmd(code.INSTALL, cli.ORDER, mdb.Config(m, nfs.SOURCE), "_install/libexec/git-core")

View File

@ -471,6 +471,15 @@ func init() {
m.Echo(_repos_remote(m, _repos_origin(m, _repos_open(m, path.Base(kit.Path(""))))))
}},
mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) {
switch m.Option(ctx.ACTION) {
case CLONE:
switch arg[0] {
case ORIGIN:
m.Push(arg[0], "https://shylinux.com/x/icons")
m.Push(arg[0], "https://shylinux.com/x/volcanos")
m.Push(arg[0], "https://shylinux.com/x/icebergs")
}
}
switch arg[0] {
case MESSAGE:
ls := kit.Split(m.Option(nfs.FILE), " /")

View File

@ -27,9 +27,9 @@ func (s java) Init(m *ice.Message) {
cli.IsAlpine(m.Message, JAVA, "openjdk8")
cli.IsAlpine(m.Message, JAVAC, "openjdk8")
cli.IsAlpine(m.Message, MVN, "maven openjdk8")
cli.IsCentos(m.Message, JAVA, "java-1.8.0-openjdk-devel.x86_64")
cli.IsCentos(m.Message, JAVAC, "java-1.8.0-openjdk-devel.x86_64")
cli.IsCentos(m.Message, MVN, "maven java-1.8.0-openjdk-devel.x86_64")
cli.IsRedhat(m.Message, JAVA, "java-1.8.0-openjdk-devel.x86_64")
cli.IsRedhat(m.Message, JAVAC, "java-1.8.0-openjdk-devel.x86_64")
cli.IsRedhat(m.Message, MVN, "maven java-1.8.0-openjdk-devel.x86_64")
s.Lang.Init(m, nfs.SCRIPT, m.Resource(""))
}
func (s java) Render(m *ice.Message, arg ...string) {

View File

@ -18,7 +18,7 @@ type node struct {
func (s node) Init(m *ice.Message) {
cli.IsAlpine(m.Message, NODE, "nodejs")
cli.IsCentos(m.Message, NODE, "nodejs")
cli.IsRedhat(m.Message, NODE, "nodejs")
}
func (s node) List(m *ice.Message, arg ...string) {
s.Code.Source(m, "", arg...)

View File

@ -15,7 +15,7 @@ type npm struct {
func (s npm) Init(m *ice.Message) {
cli.IsAlpine(m.Message, NPM)
cli.IsCentos(m.Message, NPM, "nodejs")
cli.IsRedhat(m.Message, NPM, "nodejs")
}
func (s npm) List(m *ice.Message) {
m.Cmdy(nfs.DIR, ice.USR_MODULES)