diff --git a/base/cli/runtime.go b/base/cli/runtime.go index 32a0cb94..a187b41b 100644 --- a/base/cli/runtime.go +++ b/base/cli/runtime.go @@ -149,7 +149,7 @@ const RUNTIME = "runtime" func init() { Index.MergeCommands(ice.Commands{ - RUNTIME: {Name: "runtime info=bootinfo,ifconfig,hostinfo,hostname,userinfo,procinfo,diskinfo,api,cli,cmd,env,chain auto", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{ + RUNTIME: {Name: "runtime info=bootinfo,ifconfig,hostinfo,hostname,userinfo,procinfo,diskinfo,api,cli,cmd,env,chain auto upgrade", Help: "运行环境", Actions: ice.MergeActions(ice.Actions{ ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { _runtime_init(m) }}, ice.CTX_EXIT: {Hand: func(m *ice.Message, arg ...string) { m.Conf("", "", nil) }}, IFCONFIG: {Hand: func(m *ice.Message, arg ...string) { m.Cmdy("tcp.host") }}, @@ -201,6 +201,14 @@ func init() { } }}, "chain": {Hand: func(m *ice.Message, arg ...string) { m.Echo(m.FormatChain()) }}, + "upgrade": {Hand: func(m *ice.Message, arg ...string) { + file := kit.Keys("ice", runtime.GOOS, runtime.GOARCH) + _file := file + if runtime.GOOS == WINDOWS { + _file = file + "." + m.Time() + ".exe" + } + m.Cmd("web.spide", "dev", "save", _file, "GET", ice.Info.Make.Domain+"/publish/"+file) + }}, }, ctx.ConfAction("")), Hand: func(m *ice.Message, arg ...string) { if len(arg) > 0 && arg[0] == BOOTINFO { arg = arg[1:] diff --git a/base/cli/system.go b/base/cli/system.go index a874b4d4..f3127dc8 100644 --- a/base/cli/system.go +++ b/base/cli/system.go @@ -5,6 +5,7 @@ import ( "io" "os/exec" "path" + "runtime" "strings" ice "shylinux.com/x/icebergs" @@ -52,6 +53,9 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd { m.Logs(mdb.SELECT, "mirrors cmd", bin) } } + if bin == "" && runtime.GOOS == WINDOWS { + bin = path.Join("C:/Windows", arg[0]) + } cmd := exec.Command(bin, arg[1:]...) if cmd.Dir = kit.TrimPath(m.Option(CMD_DIR)); len(cmd.Dir) > 0 { if m.Logs(mdb.PARAMS, CMD_DIR, cmd.Dir); !nfs.ExistsFile(m, cmd.Dir) { diff --git a/base/tcp/host.go b/base/tcp/host.go index 811548b0..0a04bf63 100644 --- a/base/tcp/host.go +++ b/base/tcp/host.go @@ -41,6 +41,7 @@ func _host_list(m *ice.Message, name string) { m.Push("mask", "255.0.0.0") m.Push("hard", "") } + m.SortInt(mdb.INDEX) m.StatusTimeCount() } diff --git a/base/web/cache.go b/base/web/cache.go index 61418783..e2853013 100644 --- a/base/web/cache.go +++ b/base/web/cache.go @@ -72,7 +72,8 @@ func _cache_upload(m *ice.Message, r *http.Request) (mime, name, file, size stri return "", "", "", "0" } func _cache_download(m *ice.Message, r *http.Response, file string, cb ice.Any) string { - if f, p, e := miss.CreateFile(file); !m.Warn(e, ice.ErrNotValid, DOWNLOAD) { + if f, p, e := nfs.CreateFile(m, file); m.Assert(e) { + // if f, p, e := miss.CreateFile(file); !m.Warn(e, ice.ErrNotValid, DOWNLOAD) { defer f.Close() last, base := 0, 10 nfs.CopyFile(m, f, r.Body, base*ice.MOD_BUFS, kit.Int(kit.Select("100", r.Header.Get(ContentLength))), func(count, total, step int) { diff --git a/base/web/serve.go b/base/web/serve.go index 8540f4bb..b7b5d7b7 100644 --- a/base/web/serve.go +++ b/base/web/serve.go @@ -4,6 +4,7 @@ import ( "net/http" "net/url" "path" + "runtime" "strings" ice "shylinux.com/x/icebergs" @@ -165,7 +166,16 @@ func init() { _serve_start(m) }}, SERVE_START: {Hand: func(m *ice.Message, arg ...string) { - m.Sleep30ms().Cmd(ssh.PRINTF, kit.Dict(nfs.CONTENT, "\r"+ice.Render(m, ice.RENDER_QRCODE, m.Cmdx(SPACE, DOMAIN))+ice.NL)).Cmd(ssh.PROMPT) + domain := m.Cmdx(SPACE, DOMAIN) + if ice.Info.Colors { + m.Sleep30ms().Cmd(ssh.PRINTF, kit.Dict(nfs.CONTENT, "\r"+ice.Render(m, ice.RENDER_QRCODE, domain)+ice.NL)).Cmd(ssh.PROMPT) + } else { + m.Sleep30ms().Cmd(ssh.PRINTF, kit.Dict(nfs.CONTENT, "\r"+domain+ice.NL)).Cmd(ssh.PROMPT) + } + switch runtime.GOOS { + case cli.WINDOWS: + m.Cmd(cli.SYSTEM, "explorer.exe", domain) + } }}, SERVE_REWRITE: {Hand: func(m *ice.Message, arg ...string) { if arg[0] != http.MethodGet { diff --git a/core/code/publish.go b/core/code/publish.go index d2490ab7..3f7f02ee 100644 --- a/core/code/publish.go +++ b/core/code/publish.go @@ -84,8 +84,13 @@ const PUBLISH = "publish" func init() { Index.MergeCommands(ice.Commands{ PUBLISH: {Name: "publish path auto create volcanos icebergs intshell", Help: "发布", Actions: ice.MergeActions(ice.Actions{ - ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Config(ice.CONTEXTS, _contexts) }}, - web.SERVE_START: {Hand: func(m *ice.Message, arg ...string) { _publish_file(m, ice.ICE_BIN) }}, + ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Config(ice.CONTEXTS, _contexts) }}, + web.SERVE_START: {Hand: func(m *ice.Message, arg ...string) { + if runtime.GOOS == cli.WINDOWS { + return + } + _publish_file(m, ice.ICE_BIN) + }}, ice.VOLCANOS: {Help: "火山架", Hand: func(m *ice.Message, arg ...string) { defer func() { m.EchoQRCode(m.Option(ice.MSG_USERWEB)) }() defer func() { m.Cmdy(PUBLISH, ice.CONTEXTS, ice.MISC) }() diff --git a/init.go b/init.go index 952a5526..872d589b 100644 --- a/init.go +++ b/init.go @@ -102,7 +102,9 @@ func Run(arg ...string) string { Pulse._cmd = &Command{RawHand: logs.FileLines(3)} } if len(arg) == 0 && runtime.GOOS == "windows" { - arg = append(arg, "serve", "start") + arg = append(arg, SERVE, "start", "dev", "shy") + logs.Disable(true) + os.Stderr.Close() } switch Index.Merge(Index).Begin(Pulse, arg...); kit.Select("", arg, 0) { case SERVE, SPACE: @@ -111,9 +113,7 @@ func Run(arg ...string) string { os.Exit(kit.Int(Pulse.Option(EXIT))) } default: - if runtime.GOOS == "windows" { - - } else if logs.Disable(true); len(arg) == 0 { + if logs.Disable(true); len(arg) == 0 { arg = append(arg, HELP) } if Pulse.Cmd(INIT).Cmdy(arg); strings.TrimSpace(Pulse.Result()) == "" {