From bd3660f02e7ebe7d41b01bfa37a95405c7349074 Mon Sep 17 00:00:00 2001 From: shy Date: Tue, 12 Mar 2024 13:32:07 +0800 Subject: [PATCH] add some --- base/cli/runtime.go | 4 ++++ base/ssh/script.go | 2 +- base/web/render.go | 9 +++------ base/web/spide.go | 9 ++++++++- core/code/publish.go | 14 +++++++++++--- logs.go | 1 + 6 files changed, 28 insertions(+), 11 deletions(-) diff --git a/base/cli/runtime.go b/base/cli/runtime.go index d32b0316..6ee9b6bb 100644 --- a/base/cli/runtime.go +++ b/base/cli/runtime.go @@ -18,6 +18,10 @@ import ( ) func _runtime_init(m *ice.Message) { + if ice.Info.Make.Remote == "" { + ice.Info.Make.Remote = m.Cmdx(SYSTEM, GIT, "config", "--get", "remote.origin.url") + ice.Info.Make.Module = srtings.Split(ice.Info.Make.Remote, "://")[1] + } count := kit.Int(m.Conf(RUNTIME, kit.Keys(BOOT, mdb.COUNT))) defer m.Conf(RUNTIME, kit.Keys(BOOT, mdb.COUNT), count+1) kit.For(kit.UnMarshal(kit.Format(ice.Info.Make)), func(k string, v ice.Any) { m.Conf(RUNTIME, kit.Keys(MAKE, strings.ToLower(k)), v) }) diff --git a/base/ssh/script.go b/base/ssh/script.go index 2f2111ca..b868ab7b 100644 --- a/base/ssh/script.go +++ b/base/ssh/script.go @@ -97,7 +97,7 @@ func (f *Frame) parse(m *ice.Message, h, line string) string { } msg := m.Spawn(f.target) kit.If(h == STDIO, func() { msg.Option(ice.LOG_TRACEID, log.Traceid(m)) }) - if msg.Cmdy(ls); h == STDIO && msg.IsErrNotFound() { + if msg.Cmdy(ls); h == STDIO && msg.IsErrNotFoundIndex() { msg.SetResult().Cmdy(cli.SYSTEM, ls) } kit.If(m.Option(ice.MSG_STATUS) == "", func() { m.StatusTimeCount() }) diff --git a/base/web/render.go b/base/web/render.go index db3ea793..e4c9a211 100644 --- a/base/web/render.go +++ b/base/web/render.go @@ -56,12 +56,9 @@ func Render(m *ice.Message, cmd string, args ...ice.Any) bool { case COOKIE: // value [name [path [expire]]] RenderCookie(m, arg[0], arg[1:]...) case STATUS, ice.RENDER_STATUS: // [code [text]] - if m.IsCliUA() { - RenderStatus(m.W, kit.Int(kit.Select("200", arg, 0)), kit.Select(m.Result(), strings.Join(kit.Slice(arg, 1), " "))) - } else { - m.W.WriteHeader(kit.Int(kit.Select("200", arg, 0))) - renderMsg(m) - } + // RenderStatus(m.W, kit.Int(kit.Select("200", arg, 0)), kit.Select(m.Result(), strings.Join(kit.Slice(arg, 1), " "))) + m.W.WriteHeader(kit.Int(kit.Select("200", arg, 0))) + renderMsg(m) case ice.RENDER_REDIRECT: // url [arg...] http.Redirect(m.W, m.R, m.MergeLink(arg[0], arg[1:]), http.StatusTemporaryRedirect) case ice.RENDER_DOWNLOAD: // file [type [name]] diff --git a/base/web/spide.go b/base/web/spide.go index 5df359aa..b9468229 100644 --- a/base/web/spide.go +++ b/base/web/spide.go @@ -434,6 +434,7 @@ func init() { } func HostPort(m *ice.Message, host, port string, arg ...string) string { + m.Info("what %v", host, port) p := "" if len(arg) > 0 { kit.If(kit.Select("", arg, 0), func(pod string) { p += S(pod) }) @@ -466,7 +467,13 @@ 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, total, value int)) *ice.Message { - return m.Cmd(Prefix(SPIDE), ice.DEV_IP, SPIDE_SAVE, file, http.MethodGet, link, cb) + for _, p := range []string{ice.DEV_IP, ice.DEV} { + msg := m.Cmd(Prefix(SPIDE), p, SPIDE_SAVE, file, http.MethodGet, link, cb) + if !msg.IsErr() { + return msg + } + } + return m } func SpideCache(m *ice.Message, link string) *ice.Message { return m.Cmd(Prefix(SPIDE), ice.DEV_IP, SPIDE_CACHE, http.MethodGet, link) diff --git a/core/code/publish.go b/core/code/publish.go index ddd2aebe..0165e374 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -53,12 +53,16 @@ func _publish_contexts(m *ice.Message, arg ...string) { m.OptionDefault(web.DOMAIN, host) env := []string{} - m.Option("ctx_dev_ip", web.HostPort(m, m.Cmd(tcp.HOST).Append(aaa.IP), m.Cmd(web.SERVE).Append(tcp.PORT))) + // m.Option("ctx_dev_ip", tcp.PublishLocalhost(m, web.SpideOrigin(m, ice.OPS))) + m.Option("ctx_dev_ip", web.HostPort(m, web.AdminCmd(m, tcp.HOST).Append(aaa.IP), web.AdminCmd(m, web.SERVE).Append(tcp.PORT))) // kit.If(m.Option("ctx_dev_ip"), func(p string) { env = append(env, "ctx_dev_ip", p) }) kit.If(m.Option(ice.MSG_USERPOD), func(p string) { env = append(env, cli.CTX_POD, p) }) kit.If(len(env) > 0, func() { m.Options(cli.CTX_ENV, lex.SP+kit.JoinKV(mdb.EQ, lex.SP, env...)) }) m.OptionDefault("ctx_cli", "temp=$(mktemp); if curl -h &>/dev/null; then curl -o $temp -fsSL $ctx_dev; else wget -O $temp -q $ctx_dev; fi; source $temp") - m.OptionDefault("ctx_arg", kit.JoinCmds(aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERNICK, m.Option(ice.MSG_USERNICK))) + m.OptionDefault("ctx_arg", kit.JoinCmds( + aaa.USERNAME, m.Option(ice.MSG_USERNAME), aaa.USERNICK, m.Option(ice.MSG_USERNICK), + aaa.LANGUAGE, m.Option(ice.MSG_LANGUAGE), + )) for _, k := range kit.Default(arg, ice.MISC) { switch k { @@ -69,7 +73,11 @@ func _publish_contexts(m *ice.Message, arg ...string) { case ice.CORE: m.Option(web.DOMAIN, web.SpideOrigin(m, ice.DEV)) case nfs.SOURCE, ice.DEV: - m.OptionDefault(nfs.SOURCE, ice.Info.Make.Remote) + if m.Option(ice.MSG_USERPOD) == "" { + m.Option(nfs.SOURCE, web.AdminCmd(m, cli.RUNTIME, "make.remote").Result()) + } else { + m.Option(nfs.SOURCE, web.AdminCmd(m, web.SPACE, m.Option(ice.MSG_USERPOD), cli.RUNTIME, "make.remote").Result()) + } case nfs.BINARY, ice.APP: case cli.CURL, cli.WGET: case "manual": diff --git a/logs.go b/logs.go index 567f1f23..eff19795 100644 --- a/logs.go +++ b/logs.go @@ -186,6 +186,7 @@ func (m *Message) IsErr(arg ...string) bool { } func (m *Message) IsErrNotFound() bool { return m.IsErr(ErrNotFound) } func (m *Message) IsErrNotFoundSpace() bool { return m.IsErr(ErrNotFoundSpace) } +func (m *Message) IsErrNotFoundIndex() bool { return m.IsErr(ErrNotFoundIndex) } func (m *Message) Debug(str string, arg ...Any) { if m.Option(MSG_DEBUG) == TRUE { kit.Format(str == "", func() { str = m.FormatMeta() })