diff --git a/base/ctx/command.go b/base/ctx/command.go index cbe2d01c..0ca870e1 100644 --- a/base/ctx/command.go +++ b/base/ctx/command.go @@ -10,7 +10,6 @@ import ( "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" kit "shylinux.com/x/toolkits" - "shylinux.com/x/toolkits/logs" ) func _command_list(m *ice.Message, name string) *ice.Message { @@ -121,19 +120,14 @@ func CmdList(m *ice.Message) *ice.Message { func IsOrderCmd(key string) bool { return key[0] == '/' || key[0] == '_' } func FileURI(dir string) string { - logs.Println("%v %v %v", dir, ice.Info.Make.Path, kit.Path("")) if dir == "" { return "" } else if strings.Contains(dir, "/pkg/mod/") { dir = strings.Split(dir, "/pkg/mod/")[1] - } else if path.IsAbs(dir) { - if ice.Info.Make.Path != "" && strings.HasPrefix(dir, ice.Info.Make.Path) { - dir = strings.TrimPrefix(dir, ice.Info.Make.Path) - } else if strings.HasPrefix(dir, kit.Path("")+nfs.PS) { - dir = strings.TrimPrefix(dir, kit.Path("")+nfs.PS) - } - } else if nfs.Exists(ice.Pulse, path.Join(ice.SRC, dir)) { - dir = path.Join(ice.SRC, dir) + } else if ice.Info.Make.Path != "" && strings.HasPrefix(dir, ice.Info.Make.Path) { + dir = strings.TrimPrefix(dir, ice.Info.Make.Path) + } else if strings.HasPrefix(dir, kit.Path("")+nfs.PS) { + dir = strings.TrimPrefix(dir, kit.Path("")+nfs.PS) } return path.Join(nfs.PS, ice.REQUIRE, dir) } diff --git a/base/web/dream.go b/base/web/dream.go index 8ad10f78..5b3e2287 100644 --- a/base/web/dream.go +++ b/base/web/dream.go @@ -170,7 +170,7 @@ func init() { func DreamAction() ice.Actions { return ice.MergeActions(ice.Actions{ DREAM_ACTION: {Hand: func(m *ice.Message, arg ...string) { DreamProcess(m, []string{}, arg...) }}, - }, gdb.EventsAction(DREAM_OPEN, DREAM_CLOSE, DREAM_INPUTS, DREAM_TABLES, DREAM_ACTION)) + }, gdb.EventsAction(DREAM_OPEN, DREAM_CLOSE, DREAM_INPUTS, DREAM_CREATE, DREAM_TABLES, DREAM_ACTION)) } func DreamProcess(m *ice.Message, args ice.Any, arg ...string) { if kit.HasPrefixList(arg, ice.RUN) { diff --git a/base/web/space.go b/base/web/space.go index 49b7ec0a..fcc981ed 100644 --- a/base/web/space.go +++ b/base/web/space.go @@ -36,7 +36,7 @@ func _space_dial(m *ice.Message, dev, name string, arg ...string) { next := time.Duration(rand.Intn(a*(i+1))+b*i) * time.Millisecond m.Cmd(tcp.CLIENT, tcp.DIAL, args, func(c net.Conn) { if c, e := websocket.NewClient(c, u); !m.Warn(e, tcp.DIAL, dev, SPACE, u.String()) { - defer mdb.HashCreateDeferRemove(m, kit.SimpleKV("", MASTER, dev, u.Hostname()), kit.Dict(mdb.TARGET, c))() + defer mdb.HashCreateDeferRemove(m, kit.SimpleKV("", MASTER, dev, u.Host), kit.Dict(mdb.TARGET, c))() kit.If(ice.Info.Colors, func() { once.Do(func() { m.Go(func() { _space_qrcode(m, dev) }) }) }) _space_handle(m.Spawn(), true, dev, c) i = 0 diff --git a/core/chat/macos/desktop.go b/core/chat/macos/desktop.go index c6ba4557..a9c8b84b 100644 --- a/core/chat/macos/desktop.go +++ b/core/chat/macos/desktop.go @@ -25,7 +25,7 @@ func init() { web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "桌面")) }) }}, - }, web.DreamAction(), CmdHashAction(), mdb.ImportantHashAction())}, + }, CmdHashAction(), mdb.ImportantHashAction())}, }) } diff --git a/core/code/autogen.go b/core/code/autogen.go index 533835e4..eb48d897 100644 --- a/core/code/autogen.go +++ b/core/code/autogen.go @@ -27,14 +27,13 @@ func _autogen_list(m *ice.Message) string { }[m.Option(mdb.TYPE)]) } func _autogen_source(m *ice.Message, main, file string) { - // m.Cmd(nfs.DEFS, main, nfs.Template(m, ice.SRC_MAIN_SHY)) m.Cmd(nfs.DEFS, main, m.Cmdx(nfs.CAT, ice.SRC_MAIN_SHY)) m.Cmd(nfs.PUSH, main, lex.NL+ssh.SOURCE+lex.SP+strings.TrimPrefix(file, ice.SRC+nfs.PS)+lex.NL) } func _autogen_script(m *ice.Message, file string) { m.Cmd(nfs.DEFS, file, nfs.Template(m, "demo.shy")) } func _autogen_module(m *ice.Message, file string) { m.Cmd(nfs.DEFS, file, nfs.Template(m, "demo.go")) } func _autogen_import(m *ice.Message, main string, ctx string, mod string) { - // m.Cmd(nfs.DEFS, main, nfs.Template(m, ice.SRC_MAIN_GO)) + m.Cmd(nfs.DEFS, ice.README_MD, m.Cmdx(nfs.CAT, ice.README_MD)) m.Cmd(nfs.DEFS, ice.MAKEFILE, m.Cmdx(nfs.CAT, ice.MAKEFILE)) m.Cmd(nfs.DEFS, ice.LICENSE, m.Cmdx(nfs.CAT, ice.LICENSE)) m.Cmd(nfs.DEFS, main, m.Cmdx(nfs.CAT, ice.SRC_MAIN_GO)) diff --git a/core/code/binpack.go b/core/code/binpack.go index ac58866f..0112a3ac 100644 --- a/core/code/binpack.go +++ b/core/code/binpack.go @@ -24,12 +24,6 @@ func _binpack_file(m *ice.Message, w io.Writer, arg ...string) { fmt.Fprintf(w, " \"%s\": \"%s\",\n", kit.Select(arg[0], arg, 1), "") return } - switch path.Base(arg[0]) { - case ice.GO_MOD, ice.GO_SUM: - if !strings.HasPrefix(arg[0], ice.SRC_TEMPLATE) { - return - } - } switch arg[0] { case ice.SRC_VERSION_GO, ice.SRC_BINPACK_GO, ice.ETC_LOCAL_SHY: return diff --git a/core/code/compile.go b/core/code/compile.go index 21ff359a..5f03279e 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -63,7 +63,17 @@ func init() { INSTALL: {Name: "install service*='https://golang.google.cn/dl/' version*=1.15.5", Help: "安装", Hand: func(m *ice.Message, arg ...string) { m.Cmdy(INSTALL, web.DOWNLOAD, kit.Format("%s/go%s.%s-%s.%s", m.Option(SERVICE), m.Option(VERSION), runtime.GOOS, runtime.GOARCH, kit.Select("tar.gz", "zip", runtime.GOOS == cli.WINDOWS)), ice.USR_LOCAL) }}, - }, ctx.ConfAction(cli.ENV, kit.Dict("GOPRIVATE", "shylinux.com,github.com", "GOPROXY", "https://goproxy.cn,direct", "CGO_ENABLED", "0"))), Hand: func(m *ice.Message, arg ...string) { + web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { + kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { + kit.If(cli.SystemFind(m, GO), func() { + kit.If(nfs.Exists(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME), "src/main.go")), func() { + + m.PushButton(kit.Dict(m.CommandKey(), "编译")) + }) + }) + }) + }}, + }, web.DreamAction(), ctx.ConfAction(cli.ENV, kit.Dict("GOPRIVATE", "shylinux.com,github.com", "GOPROXY", "https://goproxy.cn,direct", "CGO_ENABLED", "0"))), Hand: func(m *ice.Message, arg ...string) { defer web.ToastProcess(m)() main, file, goos, arch := _compile_target(m, arg...) env := kit.Simple(cli.PATH, cli.BinPath(), cli.HOME, kit.Select(kit.Path(""), kit.Env(cli.HOME)), mdb.Configv(m, cli.ENV), m.Optionv(cli.ENV), cli.GOOS, goos, cli.GOARCH, arch) diff --git a/core/team/plan.go b/core/team/plan.go index 7c185739..cd60a416 100644 --- a/core/team/plan.go +++ b/core/team/plan.go @@ -77,7 +77,7 @@ func init() { web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "计划")) }) }}, - }, TASK, web.DreamAction(), ctx.CmdAction(), aaa.RoleAction(ctx.COMMAND)), Hand: func(m *ice.Message, arg ...string) { + }, aaa.RoleAction(ctx.COMMAND), ctx.CmdAction(), TASK), Hand: func(m *ice.Message, arg ...string) { begin_time, end_time := _plan_scope(m, kit.Slice(arg, 0, 2)...) _plan_list(m, begin_time.Format(ice.MOD_TIME), end_time.Format(ice.MOD_TIME)) web.PushPodCmd(m, "", arg...) diff --git a/core/wiki/draw.go b/core/wiki/draw.go index 800aa8e9..e26c69ef 100644 --- a/core/wiki/draw.go +++ b/core/wiki/draw.go @@ -29,7 +29,7 @@ func init() { web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "导图")) }) }}, - }, web.DreamAction(), WikiAction("", nfs.SVG), ctx.CmdAction()), Hand: func(m *ice.Message, arg ...string) { + }, ctx.CmdAction(), WikiAction("", nfs.SVG)), Hand: func(m *ice.Message, arg ...string) { kit.If(!_wiki_list(m, arg...), func() { _wiki_show(m, arg[0]) kit.If(m.IsErr(), func() { m.Option(ice.MSG_OUTPUT, "") }) diff --git a/core/wiki/word.go b/core/wiki/word.go index a1e6f2ee..f98b6b6f 100644 --- a/core/wiki/word.go +++ b/core/wiki/word.go @@ -55,7 +55,7 @@ func init() { web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "文档")) }) }}, - }, web.DreamAction(), WikiAction("", nfs.SHY), ctx.CmdAction(), aaa.RoleAction("story.field")), Hand: func(m *ice.Message, arg ...string) { + }, aaa.RoleAction("story.field"), ctx.CmdAction(), WikiAction("", nfs.SHY)), Hand: func(m *ice.Message, arg ...string) { if m.Option(nfs.DIR_DEEP, ice.TRUE); len(arg) == 0 { arg = append(arg, nfs.SRC) } diff --git a/misc/git/repos.go b/misc/git/repos.go index 46482db4..1584b590 100644 --- a/misc/git/repos.go +++ b/misc/git/repos.go @@ -18,7 +18,6 @@ import ( "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/ctx" - "shylinux.com/x/icebergs/base/gdb" "shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" @@ -340,23 +339,27 @@ const ( const REPOS = "repos" func init() { + cache := "" web.Index.MergeCommands(ice.Commands{ - web.PP(ice.REQUIRE): {Name: "/require/shylinux.com/x/volcanos/proto.js", Hand: func(m *ice.Message, arg ...string) { + web.PP(ice.REQUIRE): {Name: "/require/shylinux.com/x/volcanos/proto.js", Actions: ice.MergeActions(ice.Actions{ + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { + cache = kit.GetValid( + func() string { return ice.Pulse.Cmdx(cli.SYSTEM, "go", "env", "GOMODCACHE") }, + func() string { + return kit.Select(kit.HomePath("go")+nfs.PS, ice.Pulse.Cmdx(cli.SYSTEM, "go", "env", "GOPATH")) + "/pkg/mod/" + }, + func() string { return ice.USR_REQUIRE }, + ) + }}, + }), Hand: func(m *ice.Message, arg ...string) { if len(arg) < 4 { m.RenderStatusBadRequest() } else if path.Join(arg[:3]...) == ice.Info.Make.Module && nfs.Exists(m, path.Join(arg[3:]...)) { m.RenderDownload(path.Join(arg[3:]...)) - } else if p := path.Join(nfs.USR, kit.Split(arg[2], mdb.AT)[0], path.Join(arg[3:]...)); nfs.Exists(m, p) { + } else if p := path.Join(nfs.USR, kit.Split(arg[2], mdb.AT)[0], path.Join(arg[3:]...)); nfs.Exists(m, p) && kit.Select("", kit.Split(arg[2], mdb.AT), 1) == ice.Info.Gomod[path.Join(arg[0], arg[1], kit.Split(arg[2], mdb.AT)[0])] { m.RenderDownload(p) } else { - p := path.Join(kit.GetValid( - func() string { return m.Cmdx(cli.SYSTEM, "go", "env", "GOMODCACHE") }, - func() string { - return kit.Select(kit.HomePath("go")+nfs.PS, m.Cmdx(cli.SYSTEM, "go", "env", "GOPATH")) + "/pkg/mod/" - }, - func() string { return ice.USR_REQUIRE }, - ), path.Join(arg...)) - if !nfs.Exists(m, p) { + if p = path.Join(cache, path.Join(arg...)); !nfs.Exists(m, p) { if p = path.Join(ice.USR_REQUIRE, path.Join(arg...)); !nfs.Exists(m, p) { ls := strings.SplitN(path.Join(arg[:3]...), mdb.AT, 2) to := path.Join(ice.USR_REQUIRE, path.Join(arg[:3]...)) @@ -541,9 +544,6 @@ func init() { mdb.HashRemove(m, m.Option(REPOS)) } }}, - web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { - kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { m.PushButton(kit.Dict(m.CommandKey(), "仓库")) }) - }}, web.DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) { kit.If(m.Option(REPOS), func(p string) { p = strings.Split(p, mdb.QS)[0] @@ -551,10 +551,18 @@ func init() { m.Cmd("", CLONE, ORIGIN, p, nfs.PATH, m.Option(cli.CMD_DIR), ice.Maps{cli.CMD_DIR: ""}) }) }}, + web.DREAM_TABLES: {Hand: func(m *ice.Message, arg ...string) { + kit.Switch(m.Option(mdb.TYPE), kit.Simple(web.SERVER, web.WORKER), func() { + kit.If(nfs.Exists(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME), ".git")), func() { + m.PushButton(kit.Dict(m.CommandKey(), "仓库")) + }) + }) + }}, code.INNER: {Hand: func(m *ice.Message, arg ...string) { _repos_inner(m, _repos_path, arg...) }}, - }, gdb.EventsAction(web.DREAM_CREATE), web.DreamAction(), mdb.HashAction(mdb.SHORT, REPOS, mdb.FIELD, "time,repos,branch,version,comment,origin"), mdb.ClearOnExitHashAction()), Hand: func(m *ice.Message, arg ...string) { + }, aaa.RoleAction(REMOTE), web.DreamAction(), mdb.ClearOnExitHashAction(), mdb.HashAction(mdb.SHORT, REPOS, mdb.FIELD, "time,repos,branch,version,comment,origin")), Hand: func(m *ice.Message, arg ...string) { if len(arg) == 0 { mdb.HashSelect(m, arg...).Sort(REPOS).Action(CLONE, PULL, PUSH, STATUS) + m.Echo(strings.ReplaceAll(m.Cmdx(code.PUBLISH, ice.CONTEXTS), "app username", "dev username")) } else if len(arg) == 1 { _repos_branch(m, _repos_open(m, arg[0])) } else if len(arg) == 2 { diff --git a/misc/git/status.go b/misc/git/status.go index 5c04baa3..1741a2bb 100644 --- a/misc/git/status.go +++ b/misc/git/status.go @@ -9,7 +9,6 @@ import ( "shylinux.com/x/icebergs/base/aaa" "shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/ctx" - "shylinux.com/x/icebergs/base/gdb" "shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" @@ -142,6 +141,10 @@ func init() { if m.Option(mdb.TYPE) != web.WORKER { return } + if !nfs.Exists(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME), ".git")) { + m.Push(mdb.TEXT, "") + return + } text := []string{} for _, line := range kit.Split(m.Cmdx(web.SPACE, m.Option(mdb.NAME), cli.SYSTEM, GIT, DIFF, "--shortstat"), mdb.FS, mdb.FS) { if list := kit.Split(line); strings.Contains(line, "file") { @@ -154,7 +157,7 @@ func init() { } m.Push(mdb.TEXT, strings.Join(text, ", ")) }}, - }, aaa.RoleAction(), gdb.EventAction(web.DREAM_TABLES), Prefix(REPOS), mdb.ImportantHashAction()), Hand: func(m *ice.Message, arg ...string) { + }, aaa.RoleAction(), web.DreamAction(), Prefix(REPOS), mdb.ImportantHashAction()), Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && arg[0] == ctx.ACTION { m.Cmdy(REPOS, arg) } else if config, err := config.LoadConfig(config.GlobalScope); err == nil && config.User.Email == "" && mdb.Config(m, aaa.EMAIL) == "" { diff --git a/misc/git/token.go b/misc/git/token.go index a0483fc8..d5dd4e5a 100644 --- a/misc/git/token.go +++ b/misc/git/token.go @@ -40,6 +40,12 @@ func init() { }).Cmd(nfs.SAVE, kit.HomePath(FILE), strings.Join(list, lex.NL)+lex.NL) m.ProcessClose() }}, - }, mdb.HashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, aaa.USERNAME, mdb.FIELD, "time,username,token"))}, + }, mdb.HashAction(mdb.EXPIRE, mdb.MONTH, mdb.SHORT, aaa.USERNAME, mdb.FIELD, "time,username,token")), Hand: func(m *ice.Message, arg ...string) { + mdb.HashSelect(m, arg...) + if len(arg) > 0 { + u := kit.ParseURL(m.Option(ice.MSG_USERWEB)) + m.EchoScript(kit.Format("%s://%s:%s@%s", u.Scheme, m.Append(aaa.USERNAME), m.Append(TOKEN), u.Host)) + } + }}, }) }