From e88ed2791d4e22c42d46841aae83d4d70e22bb97 Mon Sep 17 00:00:00 2001 From: shy Date: Tue, 3 Oct 2023 17:49:39 +0800 Subject: [PATCH] add some --- base/cli/qrcode.go | 17 ++++---- base/mdb/zone.go | 4 +- base/nfs/dir.go | 2 +- base/web/option.go | 2 - base/web/render.go | 4 +- core/chat/oauth/client.go | 10 +++-- core/code/autogen.go | 16 +++---- core/code/binpack.go | 89 +++++++++++++++++++-------------------- core/code/code.shy | 14 +++--- core/code/compile.go | 72 ++++++++++++++++++++++++------- core/code/portal.go | 12 ------ core/code/webpack.go | 53 +++++++++++------------ core/code/zml.go | 1 - misc/tmux/session.go | 8 ++-- 14 files changed, 167 insertions(+), 137 deletions(-) delete mode 100644 core/code/portal.go delete mode 100644 core/code/zml.go diff --git a/base/cli/qrcode.go b/base/cli/qrcode.go index fd8d6745..8b335613 100644 --- a/base/cli/qrcode.go +++ b/base/cli/qrcode.go @@ -60,17 +60,18 @@ func init() { } }}, }, Hand: func(m *ice.Message, arg ...string) { - m.Option(FG, kit.Select(m.Option("--plugin-fg-color"), arg, 1)) - m.Option(BG, kit.Select(m.Option("--plugin-bg-color"), arg, 2)) - switch m.Option(ice.MSG_THEME) { - case LIGHT, WHITE: - m.OptionDefault(FG, BLACK, BG, WHITE) - default: - m.OptionDefault(FG, WHITE, BG, BLACK) - } if m.IsCliUA() { + m.OptionDefault(FG, BLACK, BG, WHITE) _qrcode_cli(m, kit.Select(kit.Select(ice.Info.Make.Domain, ice.Info.Domain), arg, 0)) } else { + m.Option(FG, kit.Select(m.Option("--plugin-fg-color"), arg, 1)) + m.Option(BG, kit.Select(m.Option("--plugin-bg-color"), arg, 2)) + switch m.Option(ice.MSG_THEME) { + case LIGHT, WHITE: + m.OptionDefault(FG, BLACK, BG, WHITE) + default: + m.OptionDefault(FG, WHITE, BG, BLACK) + } m.OptionDefault(SIZE, "360") m.StatusTime(mdb.LINK, _qrcode_web(m, tcp.PublishLocalhost(m, kit.Select(m.Option(ice.MSG_USERWEB), arg, 0)))) } diff --git a/base/mdb/zone.go b/base/mdb/zone.go index 8976e34f..5398b855 100644 --- a/base/mdb/zone.go +++ b/base/mdb/zone.go @@ -207,9 +207,9 @@ func ZoneSelect(m *ice.Message, arg ...string) *ice.Message { arg = kit.Slice(arg, 0, 2) m.Fields(len(arg), kit.Select(kit.Fields(TIME, Config(m, SHORT), COUNT), Config(m, FIELDS)), ZoneField(m)) if m.Cmdy(SELECT, m.PrefixKey(), "", ZONE, arg, logs.FileLineMeta(-1)); len(arg) == 0 { - m.PushAction(Config(m, ACTION), REMOVE).StatusTimeCount().Sort(ZoneShort(m)) + m.Sort(ZoneShort(m)).PushAction(Config(m, ACTION), REMOVE).Action(CREATE).StatusTimeCount() } else if len(arg) == 1 { - m.StatusTimeCountTotal(_zone_meta(m, m.PrefixKey(), kit.Keys(HASH, HashSelectField(m, arg[0], HASH)), COUNT)) + m.Action(INSERT).StatusTimeCountTotal(_zone_meta(m, m.PrefixKey(), kit.Keys(HASH, HashSelectField(m, arg[0], HASH)), COUNT)) } return m } diff --git a/base/nfs/dir.go b/base/nfs/dir.go index 425187de..68cb50fd 100644 --- a/base/nfs/dir.go +++ b/base/nfs/dir.go @@ -200,7 +200,7 @@ func init() { m.Logs(FIND, DIR_ROOT, root, PATH, dir, m.OptionSimple(DIR_TYPE, DIR_REG)) fields := kit.Split(kit.Select(kit.Select(DIR_DEF_FIELDS, m.OptionFields()), kit.Join(kit.Slice(arg, 1)))) size, last := _dir_list(m, root, dir, 0, m.Option(DIR_DEEP) == ice.TRUE, kit.Select(TYPE_BOTH, m.Option(DIR_TYPE)), regexp.MustCompile(m.Option(DIR_REG)), fields) - m.Status(mdb.TIME, last, mdb.COUNT, kit.Split(m.FormatSize())[0], SIZE, kit.FmtSize(size), DIR_ROOT, m.Option(DIR_ROOT), kit.MDB_COST, m.FormatCost()) + m.Status(mdb.TIME, last, mdb.COUNT, kit.Split(m.FormatSize())[0], SIZE, kit.FmtSize(size), m.OptionSimple(DIR_ROOT), kit.MDB_COST, m.FormatCost()) }}, }) } diff --git a/base/web/option.go b/base/web/option.go index e5f1704d..c79a9ac5 100644 --- a/base/web/option.go +++ b/base/web/option.go @@ -43,9 +43,7 @@ func AgentIs(m Message, arg ...string) bool { func MergeURL2(m *ice.Message, url string, arg ...ice.Any) string { kit.If(m.Option(log.DEBUG) == ice.TRUE, func() { arg = append(arg, log.DEBUG, ice.TRUE) }) kit.If(m.Option(ice.MSG_USERWEB) == "", func() { - m.Debug("what %v", 123) m.Option(ice.MSG_USERWEB, Domain(ice.Pulse.Cmdv(tcp.HOST, aaa.IP), ice.Pulse.Cmdv(SERVE, tcp.PORT))) - m.Debug("what %v", 123) }) return kit.MergeURL2(m.Option(ice.MSG_USERWEB), url, arg...) } diff --git a/base/web/render.go b/base/web/render.go index 1f13a7be..bee40919 100644 --- a/base/web/render.go +++ b/base/web/render.go @@ -122,11 +122,11 @@ func RenderMain(m *ice.Message) *ice.Message { if m.IsCliUA() { return m.RenderDownload(path.Join(ice.USR_INTSHELL, ice.INDEX_SH)) } - m.OptionDefault(nfs.VERSION, RenderVersion(m)) + m.OptionDefault(nfs.VERSION, RenderVersion(m)+kit.Select("", "&pod="+m.Option(ice.MSG_USERPOD), m.Option(ice.MSG_USERPOD) != "")) return RenderTemplate(m, "main.html") } func RenderCmds(m *ice.Message, list ...ice.Any) { - m.OptionDefault(nfs.VERSION, RenderVersion(m)) + m.OptionDefault(nfs.VERSION, RenderVersion(m)+kit.Select("", "&pod="+m.Option(ice.MSG_USERPOD), m.Option(ice.MSG_USERPOD) != "")) RenderTemplate(m.Options(mdb.LIST, kit.Format(list)), "cmds.html") } func RenderPodCmd(m *ice.Message, pod, cmd string, arg ...ice.Any) { diff --git a/core/chat/oauth/client.go b/core/chat/oauth/client.go index 0be1a833..838407cf 100644 --- a/core/chat/oauth/client.go +++ b/core/chat/oauth/client.go @@ -48,19 +48,21 @@ type Client struct { login string `name:"login" role:"void"` } -var Inputs = []map[string]string{} +var Inputs = map[string]map[string]string{} func init() { - Inputs = append(Inputs, map[string]string{ + Inputs["repos"] = map[string]string{ OAUTH_URL: "/login/oauth/authorize", GRANT_URL: "/login/oauth/access_token", TOKEN_URL: "/login/oauth/access_token", USERS_URL: "/api/v1/user", API_PREFIX: "/api/v1/", TOKEN_PREFIX: "token", - }) + } +} +func (s Client) Config(m *ice.Message, arg ...string) { + s.Create(m, kit.Simple(Inputs[arg[1]], arg, web.DOMAIN, m.Cmdv(web.SPIDE, arg[1], web.CLIENT_ORIGIN))...) } - func (s Client) Inputs(m *ice.Message, arg ...string) { switch m.Option(ctx.ACTION) { case web.SSO: diff --git a/core/code/autogen.go b/core/code/autogen.go index f341ae8d..192da07f 100644 --- a/core/code/autogen.go +++ b/core/code/autogen.go @@ -19,16 +19,16 @@ import ( func _autogen_list(m *ice.Message) string { return m.OptionDefault(mdb.LIST, ice.Maps{ - "Zone": "zone id auto insert", - "Hash": "hash auto create", + "Hash": "hash auto", + "Zone": "zone id auto", "Data": "path auto", "Lang": "path auto", - "Code": "port path auto start order build download", + "Code": "port path auto start build download", }[m.Option(mdb.TYPE)]) } func _autogen_source(m *ice.Message, main, file string) { 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) + m.Cmd(nfs.PUSH, main, lex.NL+ssh.SOURCE+lex.SP+strings.TrimPrefix(file, nfs.SRC)+lex.NL) } func _autogen_script(m *ice.Message, file string) { m.Cmd(nfs.DEFS, file, nfs.Template(m, "demo.shy")) @@ -62,8 +62,8 @@ func _autogen_import(m *ice.Message, main string, ctx string, mod string) { func _autogen_version(m *ice.Message) string { if mod := _autogen_mod(m, ice.GO_MOD); !nfs.Exists(m, ".git") { m.Cmd(REPOS, "init", nfs.ORIGIN, strings.Split(kit.MergeURL2(kit.Select(m.Option(ice.MSG_USERWEB), ice.Info.Make.Remote), "/x/"+path.Base(mod)), mdb.QS)[0], mdb.NAME, path.Base(mod), nfs.PATH, nfs.PWD) - defer m.Cmd(REPOS, "add", kit.Dict(nfs.REPOS, path.Base(mod), nfs.FILE, nfs.SRC)) defer m.Cmd(REPOS, "add", kit.Dict(nfs.REPOS, path.Base(mod), nfs.FILE, ice.GO_MOD)) + defer m.Cmd(REPOS, "add", kit.Dict(nfs.REPOS, path.Base(mod), nfs.FILE, nfs.SRC)) } m.Cmd(nfs.DEFS, ".gitignore", nfs.Template(m, "gitignore")) m.Cmd(nfs.DEFS, ice.SRC_BINPACK_GO, nfs.Template(m, ice.SRC_BINPACK_GO)) @@ -124,10 +124,10 @@ func init() { } }}, nfs.SCRIPT: {Help: "脚本", Hand: func(m *ice.Message, arg ...string) { - m.Cmd(nfs.DEFS, ice.ETC_MISS_SH, nfs.Template(m, ice.ETC_MISS_SH)) + m.Cmd(nfs.DEFS, ice.ETC_MISS_SH, m.Cmdx(nfs.CAT, ice.ETC_MISS_SH)) m.Cmdy(nfs.DIR, ice.ETC_MISS_SH).Cmdy(nfs.CAT, ice.ETC_MISS_SH) }}, - nfs.MODULE: {Name: "module name*=hi help type*=Zone,Hash,Data,Code,Lang main*=main.go@key zone key", Help: "模块", Hand: func(m *ice.Message, arg ...string) { + nfs.MODULE: {Name: "module name*=hi help type*=Hash,Zone,Data,Lang,Code main*=main.go@key zone key", Help: "模块", Hand: func(m *ice.Message, arg ...string) { m.OptionDefault(mdb.ZONE, m.Option(mdb.NAME), mdb.HELP, m.Option(mdb.NAME)) m.OptionDefault(mdb.KEY, Prefix(m.Option(mdb.ZONE), m.Option(mdb.NAME))) m.Option(nfs.FILE, path.Join(m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), GO))) @@ -149,7 +149,7 @@ func init() { USR_RELEASE_CONF_GO = "usr/release/conf.go" USR_RELEASE_BINPACK_GO = "usr/release/binpack.go" ) - if m.Cmd(BINPACK, mdb.CREATE); nfs.Exists(m, ice.USR_RELEASE) && m.Option(ice.MSG_USERPOD) == "" && ice.Info.Make.Remote == "https://shylinux.com/x/contexts" { + if m.Cmd(BINPACK, mdb.CREATE); nfs.Exists(m, ice.USR_RELEASE) && m.Option(ice.MSG_USERPOD) == "" { nfs.CopyFile(m, USR_RELEASE_BINPACK_GO, ice.SRC_BINPACK_GO, func(buf []byte, offset int) []byte { kit.If(offset == 0, func() { buf = bytes.Replace(buf, []byte("package main"), []byte("package ice"), 1) }) return buf diff --git a/core/code/binpack.go b/core/code/binpack.go index c9175335..a6d23b07 100644 --- a/core/code/binpack.go +++ b/core/code/binpack.go @@ -47,53 +47,50 @@ func _binpack_dir(m *ice.Message, w io.Writer, dir string) { nfs.DirDeepAll(m, dir, nfs.PWD, func(value ice.Maps) { _binpack_file(m, w, path.Join(dir, value[nfs.PATH])) }) } func _binpack_all(m *ice.Message) { - if w, p, e := nfs.CreateFile(m, ice.SRC_BINPACK_GO); m.Assert(e) { - defer w.Close() - defer m.Echo(p) - fmt.Fprintln(w, nfs.Template(m, ice.SRC_BINPACK_GO)) - defer fmt.Fprintln(w, nfs.Template(m, "binpack_end.go")) - defer fmt.Fprint(w, lex.TB) - nfs.OptionFiles(m, nfs.DiskFile) - for _, p := range []string{ice.USR_VOLCANOS, ice.USR_INTSHELL, ice.SRC} { - _binpack_dir(m, w, p) - } - for _, p := range []string{ice.ETC_MISS_SH, ice.ETC_INIT_SHY, ice.ETC_LOCAL_SHY, ice.ETC_EXIT_SHY, ice.ETC_PATH, - ice.README_MD, ice.MAKEFILE, ice.LICENSE, ice.GO_MOD, ice.GO_SUM, - } { - _binpack_file(m, w, p) - } - list, cache := map[string]string{}, GoCache(m) - for k := range ice.Info.File { - switch ls := kit.Split(k, nfs.PS); ls[1] { - case ice.SRC: - case ice.USR: - list[path.Join(kit.Slice(ls, 1, -1)...)] = "" - default: - p := path.Join(cache, path.Join(kit.Slice(ls, 1, -1)...)) - list[path.Join(nfs.USR, strings.Split(ls[3], mdb.AT)[0], path.Join(kit.Slice(ls, 4)...))] = p - } - } - for _, k := range kit.SortedKey(list) { - v := kit.Select(k, list[k]) - m.Cmd(nfs.DIR, nfs.PWD, nfs.PATH, kit.Dict(nfs.DIR_ROOT, v, nfs.DIR_REG, kit.ExtReg(kit.Split(mdb.Config(m, "extreg"))...))).Table(func(value ice.Maps) { - if ice.Info.Make.Remote != "https://shylinux.com/x/contexts" && kit.HasPrefix(k, ice.USR_ICEBERGS) { - return - } - _binpack_file(m, w, kit.Path(v, value[nfs.PATH]), path.Join(k, value[nfs.PATH])) - }) - } - mdb.HashSelects(m).Sort(nfs.PATH).Table(func(value ice.Maps) { - if strings.HasSuffix(value[nfs.PATH], nfs.PS) { - _binpack_dir(m, w, value[nfs.PATH]) - } else { - _binpack_file(m, w, value[nfs.PATH]) - } - }) - m.Option(nfs.DIR_REG, kit.ExtReg(nfs.SHY)) - if ice.Info.Make.Remote == "https://shylinux.com/x/contexts" { - _binpack_dir(m, w, "usr/release/") + w, p, e := nfs.CreateFile(m, ice.SRC_BINPACK_GO) + m.Assert(e) + defer w.Close() + defer m.Echo(p) + fmt.Fprintln(w, nfs.Template(m, ice.SRC_BINPACK_GO)) + defer fmt.Fprintln(w, nfs.Template(m, "binpack_end.go")) + defer fmt.Fprint(w, lex.TB) + nfs.OptionFiles(m, nfs.DiskFile) + kit.For([]string{ice.USR_VOLCANOS, ice.USR_INTSHELL, ice.SRC}, func(p string) { _binpack_dir(m, w, p) }) + kit.For([]string{ + ice.ETC_MISS_SH, ice.ETC_INIT_SHY, ice.ETC_LOCAL_SHY, ice.ETC_EXIT_SHY, ice.ETC_PATH, + ice.README_MD, ice.MAKEFILE, ice.LICENSE, ice.GO_MOD, ice.GO_SUM, + }, func(p string) { _binpack_file(m, w, p) }) + list, cache := map[string]string{}, GoCache(m) + for k := range ice.Info.File { + switch ls := kit.Split(k, nfs.PS); ls[1] { + case ice.SRC: + case ice.USR: + list[path.Join(kit.Slice(ls, 1, -1)...)] = "" + default: + p := path.Join(cache, path.Join(kit.Slice(ls, 1, -1)...)) + list[path.Join(nfs.USR, strings.Split(ls[3], mdb.AT)[0], path.Join(kit.Slice(ls, 4)...))] = p } } + for _, k := range kit.SortedKey(list) { + v := kit.Select(k, list[k]) + m.Cmd(nfs.DIR, nfs.PWD, nfs.PATH, kit.Dict(nfs.DIR_ROOT, v, nfs.DIR_REG, kit.ExtReg(kit.Split(mdb.Config(m, "extreg"))...))).Table(func(value ice.Maps) { + if kit.HasPrefix(k, ice.USR_ICEBERGS) && !nfs.Exists(m, ice.USR_ICEBERGS) || m.Option(ice.MSG_USERPOD) != "" { + return + } + _binpack_file(m, w, kit.Path(v, value[nfs.PATH]), path.Join(k, value[nfs.PATH])) + }) + } + mdb.HashSelects(m).Sort(nfs.PATH).Table(func(value ice.Maps) { + if strings.HasSuffix(value[nfs.PATH], nfs.PS) { + _binpack_dir(m, w, value[nfs.PATH]) + } else { + _binpack_file(m, w, value[nfs.PATH]) + } + }) + kit.If(nfs.Exists(m, ice.USR_RELEASE) && m.Option(ice.MSG_USERPOD) == "", func() { + m.Option(nfs.DIR_REG, kit.ExtReg(nfs.SHY)) + _binpack_dir(m, w, ice.USR_RELEASE) + }) } const BINPACK = "binpack" @@ -102,7 +99,7 @@ func init() { Index.MergeCommands(ice.Commands{ BINPACK: {Name: "binpack path auto create insert", Help: "打包", Actions: ice.MergeActions(ice.Actions{ mdb.CREATE: {Hand: func(m *ice.Message, arg ...string) { _binpack_all(m) }}, - mdb.INSERT: {Name: "insert path*", Hand: func(m *ice.Message, arg ...string) { mdb.HashCreate(m, m.OptionSimple(nfs.PATH)) }}, + mdb.INSERT: {Name: "insert path*", Hand: func(m *ice.Message, arg ...string) { mdb.HashCreate(m) }}, }, mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path", "extreg", "sh,shy,py,js,css,html,png,jpg"))}, }) } diff --git a/core/code/code.shy b/core/code/code.shy index f6f36375..c62e4a0a 100644 --- a/core/code/code.shy +++ b/core/code/code.shy @@ -1,21 +1,22 @@ code.go code.shy -install.go -upgrade.go webpack.go binpack.go autogen.go compile.go publish.go +upgrade.go +install.go vimer.go inner.go xterm.go -favor.go -oauth.go -pprof.go +xterm.shy bench.go +pprof.go +favor.go +repos.go case.go c.go @@ -25,4 +26,5 @@ py.go go.go js.go css.go -html.go \ No newline at end of file +html.go +makefile.go diff --git a/core/code/compile.go b/core/code/compile.go index c089ca14..89a6abb8 100644 --- a/core/code/compile.go +++ b/core/code/compile.go @@ -8,6 +8,7 @@ import ( ice "shylinux.com/x/icebergs" "shylinux.com/x/icebergs/base/cli" "shylinux.com/x/icebergs/base/ctx" + "shylinux.com/x/icebergs/base/lex" "shylinux.com/x/icebergs/base/mdb" "shylinux.com/x/icebergs/base/nfs" "shylinux.com/x/icebergs/base/web" @@ -32,6 +33,53 @@ func _compile_target(m *ice.Message, arg ...string) (string, string, string, str return main, file, goos, arch } +func _compile_get(m *ice.Message, main string) { + block, list := false, []string{} + m.Cmd(lex.SPLIT, main, func(ls []string) { + switch ls[0] { + case "import": + if ls[1] == "(" { + block = true + } else { + list = append(list, ls[1]) + } + case ")": + block = false + default: + if block { + list = append(list, kit.Select("", ls, -1)) + } + } + }) + _list := map[string]bool{} + m.Cmd(lex.SPLIT, ice.GO_MOD, func(ls []string) { + switch ls[0] { + case "module": + _list[ls[1]] = true + case "require": + if ls[1] == "(" { + block = true + } else { + _list[ls[1]] = true + } + case ")": + block = false + default: + if block { + _list[kit.Select("", ls, 0)] = true + } + } + }) + kit.For(list, func(p string) { + if _, ok := _list[p]; ok { + return + } else if ls := kit.Slice(strings.Split(p, nfs.PS), 0, 3); _list[path.Join(ls...)] { + return + } + m.Cmd(cli.SYSTEM, GO, "get", p) + }) +} + const COMPILE = "compile" func init() { @@ -64,11 +112,9 @@ func init() { 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) }}, 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(), "构建")) - }) + kit.If(m.Option(mdb.TYPE) == web.WORKER, func() { + kit.If(nfs.Exists(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME), ice.SRC_MAIN_GO)), func() { + kit.If(cli.SystemFind(m, GO), func() { m.PushButton(kit.Dict(m.CommandKey(), "构建")) }) }) }) }}, @@ -79,20 +125,14 @@ func init() { 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) kit.If(runtime.GOOS == cli.WINDOWS, func() { env = append(env, "GOPATH", kit.HomePath(GO), "GOCACHE", kit.HomePath("go/go-build")) }) m.Options(cli.CMD_ENV, env).Cmd(AUTOGEN, VERSION) + _compile_get(m, main) defer m.StatusTime(VERSION, strings.TrimPrefix(m.Cmdx(cli.SYSTEM, GO, VERSION), "go version")) - kit.For([]string{"shylinux.com/x/ice"}, func(p string) { - kit.If(!strings.Contains(m.Cmdx(nfs.CAT, ice.GO_MOD), p), func() { - m.Cmd(cli.SYSTEM, GO, "get", p) - }) - }) if msg := m.Cmd(cli.SYSTEM, GO, cli.BUILD, "-ldflags", "-w -s", "-o", file, main, ice.SRC_VERSION_GO, ice.SRC_BINPACK_GO); !cli.IsSuccess(msg) { m.Copy(msg) - return - } - m.Logs(nfs.SAVE, nfs.TARGET, file, nfs.SOURCE, main) - m.Cmdy(nfs.DIR, file, "time,path,size,hash,link") - if !m.IsCliUA() { - kit.If(strings.Contains(file, ice.ICE), func() { m.Cmdy(PUBLISH, ice.CONTEXTS, ice.APP) }) + } else { + m.Logs(nfs.SAVE, nfs.TARGET, file, nfs.SOURCE, main) + m.Cmdy(nfs.DIR, file, "time,path,size,hash,link") + kit.If(!m.IsCliUA() && strings.Contains(file, ice.ICE), func() { m.Cmdy(PUBLISH, ice.CONTEXTS, ice.APP) }) } }}, }) diff --git a/core/code/portal.go b/core/code/portal.go deleted file mode 100644 index 6c5cf5e7..00000000 --- a/core/code/portal.go +++ /dev/null @@ -1,12 +0,0 @@ -package code - -import ice "shylinux.com/x/icebergs" - -const PORTAL = "portal" - -func init() { - Index.MergeCommands(ice.Commands{ - PORTAL: {Name: "portal path auto", Help: "门户", Hand: func(m *ice.Message, arg ...string) { - }}, - }) -} diff --git a/core/code/webpack.go b/core/code/webpack.go index d849e217..746929b2 100644 --- a/core/code/webpack.go +++ b/core/code/webpack.go @@ -19,13 +19,14 @@ import ( func _volcanos(m *ice.Message, p ...string) string { return ice.USR_VOLCANOS + path.Join(p...) } func _publish(m *ice.Message, p ...string) string { return ice.USR_PUBLISH + path.Join(p...) } func _require(m *ice.Message, p string) string { - p = strings.Replace(p, ice.USR_MODULES, "/require/modules/", 1) - if kit.HasPrefix(p, nfs.SRC, nfs.USR) { - return path.Join("/require/", p) - } else if strings.HasPrefix(p, "/require/") { - return path.Join(nfs.PS, strings.TrimPrefix(p, ice.USR_VOLCANOS)) - } else { + if kit.HasPrefix(p, ice.USR_MODULES) { + return path.Join("/require/modules/", strings.TrimPrefix(p, ice.USR_MODULES)) + } else if kit.HasPrefix(p, ice.USR_VOLCANOS) { return path.Join("/volcanos/", strings.TrimPrefix(p, ice.USR_VOLCANOS)) + } else if kit.HasPrefix(p, nfs.SRC, nfs.USR) { + return path.Join("/require/", p) + } else { + return path.Join("/volcanos/", p) } } func _webpack_css(m *ice.Message, css, js io.Writer, p string) { @@ -45,7 +46,9 @@ func _webpack_end(m *ice.Message, js io.Writer, p string) { fmt.Fprintln(js, `Volcanos.meta.cache["`+_require(m, p)+`"] = []`) } func _webpack_cache(m *ice.Message, dir string, write bool) { - if _, e := nfs.DiskFile.StatFile(ice.USR_VOLCANOS); os.IsNotExist(e) { + if m.Option(ice.MSG_USERPOD) != "" { + return + } else if _, e := nfs.DiskFile.StatFile(ice.USR_VOLCANOS); os.IsNotExist(e) { return } css, _, e := nfs.CreateFile(m, path.Join(dir, PAGE_CACHE_CSS)) @@ -57,25 +60,23 @@ func _webpack_cache(m *ice.Message, dir string, write bool) { if !write { return } - for _, k := range []string{LIB, PANEL, PLUGIN} { + kit.For([]string{LIB, PANEL, PLUGIN}, func(k string) { nfs.DirDeepAll(m, dir, k, func(value ice.Maps) { - if kit.Ext(value[nfs.PATH]) == CSS { + kit.If(kit.Ext(value[nfs.PATH]) == CSS, func() { _webpack_css(m, css, js, value[nfs.PATH]) - } + }) }) - } - for _, k := range []string{LIB, PANEL, PLUGIN} { + }) + kit.For([]string{LIB, PANEL, PLUGIN}, func(k string) { nfs.DirDeepAll(m, dir, k, func(value ice.Maps) { - if kit.Ext(value[nfs.PATH]) == JS { + kit.If(kit.Ext(value[nfs.PATH]) == JS, func() { _webpack_js(m, js, value[nfs.PATH]) - } + }) }) - } - for _, k := range []string{ice.FRAME_JS} { - m.Option(nfs.DIR_ROOT, _volcanos(m)) - _webpack_js(m, js, k) - m.Option(nfs.DIR_ROOT, "") - } + }) + kit.For([]string{ice.FRAME_JS}, func(k string) { + _webpack_js(m, js, path.Join(dir, k)) + }) m.Cmd(nfs.DIR, "src/template/web.chat.header/theme/", func(value ice.Maps) { _webpack_css(m, css, js, value[nfs.PATH]) }) @@ -124,20 +125,20 @@ const WEBPACK = "webpack" func init() { Index.MergeCommands(ice.Commands{ WEBPACK: {Name: "webpack path auto create remove", Help: "打包", Actions: ice.MergeActions(ice.Actions{ - mdb.CREATE: {Help: "发布", Hand: func(m *ice.Message, arg ...string) { + mdb.CREATE: {Hand: func(m *ice.Message, arg ...string) { _webpack_cache(m.Spawn(), _volcanos(m), true) - _webpack_can(m) + // _webpack_can(m) m.Cmdy("") }}, - mdb.REMOVE: {Help: "开发", Hand: func(m *ice.Message, arg ...string) { + mdb.REMOVE: {Hand: func(m *ice.Message, arg ...string) { _webpack_cache(m.Spawn(), _volcanos(m), false) - m.Cmdy(nfs.DIR, _volcanos(m, PAGE)) + m.Cmdy("") }}, mdb.INSERT: {Name: "insert path*", Hand: func(m *ice.Message, arg ...string) { - mdb.HashCreate(m, m.OptionSimple(nfs.PATH)) + mdb.HashCreate(m) }}, cli.BUILD: {Name: "build name*=hi", Hand: func(m *ice.Message, arg ...string) { - kit.If(!nfs.Exists(m, USR_PUBLISH_CAN_JS), func() { m.Cmd("", mdb.CREATE) }) + // kit.If(!nfs.Exists(m, USR_PUBLISH_CAN_JS), func() { m.Cmd("", mdb.CREATE) }) _webpack_build(m, _publish(m, m.Option(mdb.NAME))) }}, nfs.TRASH: {Hand: func(m *ice.Message, arg ...string) { diff --git a/core/code/zml.go b/core/code/zml.go deleted file mode 100644 index e85e2534..00000000 --- a/core/code/zml.go +++ /dev/null @@ -1 +0,0 @@ -package code diff --git a/misc/tmux/session.go b/misc/tmux/session.go index 387df6dc..b5b8f449 100644 --- a/misc/tmux/session.go +++ b/misc/tmux/session.go @@ -82,9 +82,11 @@ func init() { }, Commands: ice.Commands{ SESSION: {Name: "session session window pane cmds auto", Help: "会话", Actions: ice.Actions{ web.DREAM_CREATE: {Hand: func(m *ice.Message, arg ...string) { - if !m.Warn(!nfs.Exists(m, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME))), ice.ErrNotFound) { - m.Cmd("", mdb.CREATE) - } + m.Go(func() { + nfs.Exists(m.Sleep3s(), path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME)), func(p string) { + m.Cmd("", mdb.CREATE) + }) + }) }}, mdb.INPUTS: {Hand: func(m *ice.Message, arg ...string) { if m.Option(ctx.ACTION) == SCRIPT {