1
0
forked from x/icebergs
This commit is contained in:
harveyshao 2022-04-25 15:11:39 +08:00
parent d3e32837c4
commit 8df81a51a8
9 changed files with 37 additions and 24 deletions

View File

@ -47,12 +47,13 @@ func _user_search(m *ice.Message, name, text string) {
})
}
func UserRoot(m *ice.Message, arg ...string) { // password username userrole
func UserRoot(m *ice.Message, arg ...string) *ice.Message { // password username userrole
username := m.Option(ice.MSG_USERNAME, kit.Select(ice.Info.UserName, arg, 1))
userrole := m.Option(ice.MSG_USERROLE, kit.Select(ROOT, arg, 2))
if len(arg) > 0 {
_user_create(m, userrole, username, kit.Select("", arg, 0))
}
return m
}
func UserRole(m *ice.Message, username interface{}) (role string) {
if role = VOID; username == ice.Info.UserName {

View File

@ -3,7 +3,6 @@ package cli
import (
"bytes"
"io"
"os"
"os/exec"
"path"
"strings"
@ -59,7 +58,6 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd {
if len(cmd.Env) > 0 {
m.Log_EXPORT(CMD_ENV, cmd.Env)
}
m.Debug("wht%v", os.Getenv(PATH))
return cmd
}
func _system_out(m *ice.Message, out string) io.Writer {

View File

@ -391,8 +391,8 @@ func init() {
}
}
if strings.HasPrefix(arg[0], "ice.") && m.Option(ice.POD) != "" {
aaa.UserRoot(m)
_share_local(m, "bin/ice.bin")
_share_local(aaa.UserRoot(m), ice.BIN_ICE_BIN)
// _share_local(aaa.UserRoot(m), arg[0])
return
}
_share_local(m, m.Conf(SERVE, kit.Keym(ice.PUBLISH)), path.Join(arg...))

View File

@ -81,13 +81,14 @@ func _share_local(m *ice.Message, arg ...string) {
size = s.Size()
}
if p == "bin/ice.bin" {
aaa.UserRoot(m)
}
// 上传文件
m.Cmd(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, m.MergeURL2(SHARE_PROXY, nfs.PATH, ""),
SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, nfs.SIZE, size, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, "@"+p)
if p == "bin/ice.bin" {
aaa.UserRoot(m).Cmd(SPACE, m.Option(ice.POD), SPIDE, "submit", m.MergeURL2(SHARE_PROXY, nfs.PATH, ""), m.Option(ice.POD), p, size, cache.Format(ice.MOD_TIME))
} else {
m.Cmd(SPACE, m.Option(ice.POD), SPIDE, ice.DEV, SPIDE_RAW, m.MergeURL2(SHARE_PROXY, nfs.PATH, ""),
SPIDE_PART, m.OptionSimple(ice.POD), nfs.PATH, p, nfs.SIZE, size, CACHE, cache.Format(ice.MOD_TIME), UPLOAD, "@"+p)
}
if s, e := os.Stat(pp); e == nil && !s.IsDir() {
p = pp

View File

@ -14,6 +14,7 @@ import (
"time"
ice "shylinux.com/x/icebergs"
"shylinux.com/x/icebergs/base/aaa"
"shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
@ -350,15 +351,18 @@ func init() {
conf := m.Confm(cli.RUNTIME, "conf")
m.Cmd(SPIDE, mdb.CREATE, ice.OPS, kit.Select("http://127.0.0.1:9020", conf["ctx_ops"]))
m.Cmd(SPIDE, mdb.CREATE, ice.DEV, kit.Select("http://contexts.woa.com:80", conf["ctx_dev"]))
m.Cmd(SPIDE, mdb.CREATE, ice.SHY, kit.Select("https://contexts.com.cn:443", conf["ctx_shy"]))
// m.Cmd(SPIDE, mdb.CREATE, ice.SHY, kit.Select("https://shylinux.com:443", conf["ctx_shy"]))
m.Cmd(SPIDE, mdb.CREATE, ice.SHY, kit.Select("https://shylinux.com:443", conf["ctx_shy"]))
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, SPIDE, "submit")
}},
mdb.CREATE: {Name: "create name address", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
_spide_create(m, m.Option(mdb.NAME), m.Option(ADDRESS))
}},
MERGE: {Name: "merge name path", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
MERGE: {Name: "merge name path", Help: "拼接", Hand: func(m *ice.Message, arg ...string) {
m.Echo(kit.MergeURL2(m.Cmd(SPIDE, arg[0], ice.OptionFields("")).Append(CLIENT_URL), arg[1], arg[2:]))
}},
"submit": {Name: "submit dev pod path size cache", Help: "发布", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(SPIDE, ice.DEV, SPIDE_RAW, m.Option("dev"), SPIDE_PART, "pod", m.Option("pod"), nfs.PATH, "bin/ice.bin", UPLOAD, "@"+"bin/ice.bin")
}},
}, mdb.HashAction()), Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) < 2 || arg[0] == "" || (len(arg) > 3 && arg[3] == "") {
mdb.HashSelect(m, kit.Slice(arg, 0, 1)...)

View File

@ -59,16 +59,20 @@ func init() {
m.Cmdy(BINPACK, mdb.EXPORT)
}},
BINPACK: {Name: "binpack", Help: "打包模式", Hand: func(m *ice.Message, arg ...string) {
m.Cmd(nfs.LINK, ice.GO_MOD, path.Join(ice.SRC_RELEASE, ice.GO_MOD))
m.Cmd(nfs.LINK, ice.GO_SUM, path.Join(ice.SRC_RELEASE, ice.GO_SUM))
if kit.FileExists(ice.SRC_RELEASE) {
m.Cmd(nfs.LINK, ice.GO_MOD, path.Join(ice.SRC_RELEASE, ice.GO_MOD))
m.Cmd(nfs.LINK, ice.GO_SUM, path.Join(ice.SRC_RELEASE, ice.GO_SUM))
}
m.Cmdy(nfs.CAT, ice.GO_MOD)
m.Cmdy(AUTOGEN, BINPACK)
m.ToastSuccess()
m.ProcessInner()
}},
DEVPACK: {Name: "devpack", Help: "开发模式", Hand: func(m *ice.Message, arg ...string) {
m.Cmd(nfs.LINK, ice.GO_MOD, path.Join(ice.SRC_DEBUG, ice.GO_MOD))
m.Cmd(nfs.LINK, ice.GO_SUM, path.Join(ice.SRC_DEBUG, ice.GO_SUM))
if kit.FileExists(ice.SRC_DEBUG) {
m.Cmd(nfs.LINK, ice.GO_MOD, path.Join(ice.SRC_DEBUG, ice.GO_MOD))
m.Cmd(nfs.LINK, ice.GO_SUM, path.Join(ice.SRC_DEBUG, ice.GO_SUM))
}
m.Cmdy(nfs.CAT, ice.GO_MOD)
m.Cmdy(WEBPACK, mdb.REMOVE)
m.ToastSuccess()

View File

@ -13,7 +13,7 @@ import (
func _refer_show(m *ice.Message, text string, arg ...string) {
list := [][]string{}
for _, v := range kit.Split(strings.TrimSpace(text), ice.NL, ice.NL) {
if ls := kit.Split(v); len(ls) == 1 {
if ls := kit.Split(v, " ", " "); len(ls) == 1 {
list = append(list, []string{path.Base(ls[0]), ls[0]})
} else {
list = append(list, ls)

View File

@ -128,7 +128,7 @@ func init() {
if ls := strings.Split(p, ice.PS); m.Cmd(web.DREAM, ls[3]).Length() > 0 {
r.URL.RawQuery += kit.Select("", "&", len(r.URL.RawQuery) > 1) + "pod=" + ls[3]
}
r.URL.Path = "/share/local/bin/ice.bin"
r.URL.Path = "/publish/ice.bin"
m.Info("rewrite %v -> %v", p, r.URL.Path)
}
} else if strings.HasPrefix(p, "/x/") {
@ -162,8 +162,13 @@ func init() {
m.Log_CREATE(REPOS, repos)
}
case "upload-pack": // 下载代码
aaa.UserRoot(m)
if kit.Select("", arg, 1) == "info" && m.Cmd(web.DREAM, arg[0]).Length() > 0 {
m.Cmd(web.SPACE, arg[0], "web.code.git.status", "submit", m.MergeURL2("/x/")+arg[0])
}
if !kit.FileExists(path.Join(repos)) {
web.RenderStatus(m, 404, kit.Format("not found: %s", arg[0]))
return
}
}

View File

@ -276,8 +276,8 @@ func init() {
"branch_switch": {Name: "branch_switch", Help: "切换", Hand: func(m *ice.Message, arg ...string) {
_repos_cmd(m.Spawn(), m.Option(REPOS), "checkout", m.Option(BRANCH))
}},
"upload": {Name: "upload", Help: "发布", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(cli.SYSTEM, GIT, PUSH, "-u", m.MergeURL2("/x/")+kit.Select(ice.CONTEXTS, m.Option(ice.MSG_USERPOD)))
"submit": {Name: "submit", Help: "发布", Hand: func(m *ice.Message, arg ...string) {
m.Cmdy(cli.SYSTEM, GIT, PUSH, "-u", kit.Select(m.MergeURL2("/x/")+kit.Select(ice.CONTEXTS, m.Option(ice.MSG_USERPOD)), arg, 0))
m.Cmdy(code.PUBLISH, ice.CONTEXTS, ice.MISC, ice.CORE)
}},
BRANCH: {Name: "branch", Help: "分支", Hand: func(m *ice.Message, arg ...string) {
@ -307,7 +307,7 @@ func init() {
}},
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
if len(arg) == 0 {
m.Action(PULL, MAKE, PUSH, TAGS, STASH, PIE, "upload")
m.Action(PULL, MAKE, PUSH, TAGS, STASH, PIE, "submit")
files, adds, dels, last := _status_list(m)
m.Status("files", files, "adds", adds, "dels", dels, "last", last.Format(ice.MOD_TIME))