mirror of
https://shylinux.com/x/icebergs
synced 2025-04-25 17:18:05 +08:00
opt some
This commit is contained in:
parent
6e1cc3119f
commit
70c4544bf7
@ -37,7 +37,7 @@ func init() {
|
||||
}
|
||||
|
||||
m.Cmd(FOREVER, STOP)
|
||||
m.Cmdy(FOREVER, kit.Select(os.Args[0], nfs.PWD+ice.BIN_ICE_BIN, kit.FileExists(ice.BIN_ICE_BIN)),
|
||||
m.Cmdy(FOREVER, kit.Select(os.Args[0], nfs.PWD+ice.BIN_ICE_BIN, nfs.ExistsFile(m, ice.BIN_ICE_BIN)),
|
||||
"serve", START, ice.DEV, "", aaa.USERNAME, aaa.ROOT, aaa.PASSWORD, aaa.ROOT, arg)
|
||||
}},
|
||||
RESTART: {Name: "restart", Help: "重启", Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -35,15 +35,6 @@ func init() {
|
||||
if IsAlpine(m, "git"); !IsAlpine(m, "go", "go git") {
|
||||
mdb.ZoneInsert(m, CLI, "go", CMD, kit.Format("install download https://golang.google.cn/dl/go1.15.5.%s-%s.tar.gz usr/local", runtime.GOOS, runtime.GOARCH))
|
||||
}
|
||||
|
||||
IsAlpine(m, "npm")
|
||||
IsAlpine(m, "node", "nodejs")
|
||||
IsAlpine(m, "java", "openjdk8")
|
||||
IsAlpine(m, "javac", "openjdk8")
|
||||
IsAlpine(m, "mvn", "maven openjdk8")
|
||||
IsAlpine(m, "python", "python2")
|
||||
IsAlpine(m, "python2")
|
||||
IsAlpine(m, "python3")
|
||||
})
|
||||
}},
|
||||
mdb.INSERT: {Name: "insert cli osid cmd", Help: "添加"},
|
||||
@ -65,7 +56,16 @@ func init() {
|
||||
func IsAlpine(m *ice.Message, arg ...string) bool {
|
||||
if strings.Contains(m.Conf(RUNTIME, kit.Keys(HOST, OSID)), ALPINE) {
|
||||
if len(arg) > 0 {
|
||||
m.Cmd(mdb.INSERT, m.Prefix(MIRRORS), "", mdb.ZONE, arg[0], OSID, ALPINE, CMD, "system apk add "+kit.Select(arg[0], arg, 1))
|
||||
m.Cmd(mdb.INSERT, kit.Keys(CLI, MIRRORS), "", mdb.ZONE, arg[0], OSID, ALPINE, CMD, "system apk add "+kit.Select(arg[0], arg, 1))
|
||||
}
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
func IsCentos(m *ice.Message, arg ...string) bool {
|
||||
if strings.Contains(m.Conf(RUNTIME, kit.Keys(HOST, OSID)), CENTOS) {
|
||||
if len(arg) > 0 {
|
||||
m.Cmd(mdb.INSERT, kit.Keys(CLI, MIRRORS), "", mdb.ZONE, arg[0], OSID, CENTOS, CMD, "yum install -y "+kit.Select(arg[0], arg, 1))
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
@ -27,6 +27,8 @@ func _runtime_init(m *ice.Message) {
|
||||
m.Conf(RUNTIME, kit.Keys(HOST, PID), os.Getpid())
|
||||
m.Conf(RUNTIME, kit.Keys(HOST, HOME), kit.Env(HOME))
|
||||
m.Conf(RUNTIME, kit.Keys(HOST, MAXPROCS), runtime.GOMAXPROCS(0))
|
||||
m.Conf(RUNTIME, mdb.META, "")
|
||||
m.Conf(RUNTIME, mdb.HASH, "")
|
||||
|
||||
// 启动目录 boot
|
||||
m.Conf(RUNTIME, kit.Keys(BOOT, HOSTNAME), kit.Env("HOSTNAME"))
|
||||
@ -47,9 +49,9 @@ func _runtime_init(m *ice.Message) {
|
||||
m.Conf(RUNTIME, kit.Keys(BOOT, mdb.COUNT), kit.Int(m.Conf(RUNTIME, kit.Keys(BOOT, mdb.COUNT)))+1)
|
||||
bin := _system_find(m, os.Args[0])
|
||||
m.Conf(RUNTIME, kit.Keys(BOOT, ice.BIN), bin)
|
||||
if s, e := os.Stat(bin); e == nil {
|
||||
if s, e := nfs.StatFile(m, bin); e == nil {
|
||||
m.Conf(RUNTIME, kit.Keys(BOOT, nfs.SIZE), kit.FmtSize(s.Size()))
|
||||
if f, e := os.Open(bin); e == nil {
|
||||
if f, e := nfs.OpenFile(m, bin); e == nil {
|
||||
defer f.Close()
|
||||
m.Conf(RUNTIME, kit.Keys(BOOT, mdb.HASH), kit.Hashs(f))
|
||||
}
|
||||
|
@ -42,7 +42,7 @@ func _system_cmd(m *ice.Message, arg ...string) *exec.Cmd {
|
||||
|
||||
// 运行目录
|
||||
if cmd.Dir = m.Option(CMD_DIR); len(cmd.Dir) > 0 {
|
||||
if m.Logs(mdb.EXPORT, CMD_DIR, cmd.Dir); !kit.FileExists(cmd.Dir) {
|
||||
if m.Logs(mdb.EXPORT, CMD_DIR, cmd.Dir); !nfs.ExistsFile(m, cmd.Dir) {
|
||||
file.MkdirAll(cmd.Dir, ice.MOD_DIR)
|
||||
}
|
||||
}
|
||||
@ -81,7 +81,7 @@ func _system_find(m *ice.Message, bin string, dir ...string) string {
|
||||
dir = append(dir, strings.Split(kit.Env(PATH), ice.DF)...)
|
||||
}
|
||||
for _, p := range dir {
|
||||
if kit.FileExists(path.Join(p, bin)) {
|
||||
if nfs.ExistsFile(m, path.Join(p, bin)) {
|
||||
return kit.Path(path.Join(p, bin))
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ func FileURI(dir string) string {
|
||||
if strings.HasPrefix(dir, ice.SRC) {
|
||||
return path.Join("/require", dir)
|
||||
}
|
||||
if kit.FileExists(path.Join(ice.SRC, dir)) {
|
||||
if nfs.ExistsFile(ice.Pulse, path.Join(ice.SRC, dir)) {
|
||||
return path.Join("/require/src/", dir)
|
||||
}
|
||||
return dir
|
||||
|
@ -173,19 +173,13 @@ const DIR = "dir"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
DIR: {Name: "dir path field auto upload what", Help: "目录", Actions: ice.Actions{
|
||||
DIR: {Name: "dir path field auto upload", Help: "目录", Actions: ice.Actions{
|
||||
mdb.UPLOAD: {Name: "upload", Help: "上传", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy("web.cache", "upload_watch", m.Option(PATH))
|
||||
}},
|
||||
TRASH: {Name: "trash", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(TRASH, mdb.CREATE, m.Option(PATH))
|
||||
}},
|
||||
"what": {Name: "trash", Help: "what", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(DIR_ROOT, "usr/volcanos/plugin/local/code/inner/")
|
||||
m.Option(DIR_DEEP, "true")
|
||||
m.Cmdy(DIR, PWD)
|
||||
m.Sort("path")
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.Option(DIR_ROOT) != "" {
|
||||
m.Logs(mdb.SELECT, DIR_ROOT, m.Option(DIR_ROOT))
|
||||
|
@ -37,7 +37,7 @@ func init() {
|
||||
m.Cmdy("cli.system", "tar", "zcvf", arg)
|
||||
return
|
||||
|
||||
file, err := os.Create(arg[0])
|
||||
file, _, err := CreateFile(m, arg[0])
|
||||
m.Assert(err)
|
||||
defer file.Close()
|
||||
|
||||
@ -67,7 +67,7 @@ func init() {
|
||||
return
|
||||
}
|
||||
|
||||
file, err := os.Open(p)
|
||||
file, err := OpenFile(m, p)
|
||||
if m.Warn(err) {
|
||||
return
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package web
|
||||
|
||||
import (
|
||||
"os"
|
||||
"time"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
@ -127,7 +126,7 @@ func _story_write(m *ice.Message, scene, name, text string, arg ...string) {
|
||||
func _story_catch(m *ice.Message, scene, name string, arg ...string) {
|
||||
if last := m.Richs(STORY, HEAD, name, nil); last != nil {
|
||||
if t, e := time.ParseInLocation(ice.MOD_TIME, kit.Format(last[mdb.TIME]), time.Local); e == nil {
|
||||
if s, e := os.Stat(name); e == nil && s.ModTime().Before(t) {
|
||||
if s, e := nfs.StatFile(m, name); e == nil && s.ModTime().Before(t) {
|
||||
m.Push(name, last, []string{mdb.TIME, mdb.COUNT, mdb.KEY})
|
||||
m.Logs("info", "file", "exists")
|
||||
m.Echo("%s", last[LIST])
|
||||
|
@ -49,14 +49,14 @@ func _dream_list(m *ice.Message) *ice.Message {
|
||||
|
||||
func _dream_show(m *ice.Message, name string) {
|
||||
if !strings.Contains(name, "-") || !strings.HasPrefix(name, "20") {
|
||||
name = m.Time("20060102-") + kit.ReplaceAll(name, "-", "_")
|
||||
name = m.Time("20060102-") + name
|
||||
}
|
||||
defer m.ProcessOpen(MergePod(m, m.Option(mdb.NAME, name)))
|
||||
defer m.Echo(MergePod(m, m.Option(mdb.NAME, name)))
|
||||
// defer m.PushRefresh()
|
||||
|
||||
p := path.Join(ice.USR_LOCAL_WORK, name)
|
||||
if pid := m.Cmdx(nfs.CAT, path.Join(p, ice.Info.PidPath)); pid != "" && kit.FileExists("/proc/"+pid) {
|
||||
if pid := m.Cmdx(nfs.CAT, path.Join(p, ice.Info.PidPath)); pid != "" && nfs.ExistsFile(m, "/proc/"+pid) {
|
||||
m.Info("already exists %v", pid)
|
||||
return // 已经启动
|
||||
} else if m.Cmd(SPACE, name).Length() > 0 {
|
||||
@ -117,18 +117,25 @@ const DREAM = "dream"
|
||||
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
DREAM: {Name: "dream name path auto start", Help: "梦想家", Actions: ice.MergeActions(ice.Actions{
|
||||
DREAM: {Name: "dream name path auto create", Help: "梦想家", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) { m.Config(nfs.SCRIPT, _dream_script) }},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case nfs.REPOS:
|
||||
m.Cmd("web.code.git.server", func(value ice.Maps) {
|
||||
m.Push(nfs.PATH, MergeLink(m, path.Join("/x/", value[nfs.PATH]+".git")))
|
||||
})
|
||||
m.Sort(nfs.PATH)
|
||||
default:
|
||||
_dream_list(m).Cut("name,status,time")
|
||||
}
|
||||
}},
|
||||
cli.START: {Name: "start name=hi repos", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.CREATE: {Name: "create name=hi repos", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
||||
_dream_show(m, m.Option(mdb.NAME, kit.Select(path.Base(m.Option(nfs.REPOS)), m.Option(mdb.NAME))))
|
||||
}},
|
||||
cli.START: {Name: "start", Help: "启动", Hand: func(m *ice.Message, arg ...string) {
|
||||
_dream_show(m, m.Option(mdb.NAME))
|
||||
}},
|
||||
cli.OPEN: {Name: "open", Help: "打开", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.ProcessOpen(MergePod(m, m.Option(mdb.NAME), "", ""))
|
||||
}},
|
||||
@ -141,7 +148,7 @@ func init() {
|
||||
cli.STOP: {Name: "stop", Help: "停止", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(SPACE, mdb.MODIFY, m.OptionSimple(mdb.NAME), mdb.STATUS, cli.STOP)
|
||||
m.Cmd(SPACE, m.Option(mdb.NAME), ice.EXIT)
|
||||
m.ProcessRefresh30ms()
|
||||
m.ProcessRefresh3s()
|
||||
}},
|
||||
DREAM_STOP: {Name: "dream.stop type name", Help: "停止", Hand: func(m *ice.Message, arg ...string) {
|
||||
if m.CmdAppend(SPACE, m.Option(mdb.NAME), mdb.STATUS) == cli.STOP {
|
||||
|
@ -8,7 +8,6 @@ import (
|
||||
"mime/multipart"
|
||||
"net/http"
|
||||
"net/url"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"time"
|
||||
@ -141,7 +140,7 @@ func _spide_body(m *ice.Message, method string, arg ...string) (io.Reader, ice.M
|
||||
head[ContentType] = ContentJSON
|
||||
|
||||
case SPIDE_FILE:
|
||||
if f, e := os.Open(arg[1]); m.Assert(e) {
|
||||
if f, e := nfs.OpenFile(m, arg[1]); m.Assert(e) {
|
||||
defer f.Close()
|
||||
body, arg = f, arg[2:]
|
||||
}
|
||||
|
1
conf.go
1
conf.go
@ -93,6 +93,7 @@ const ( // DIR
|
||||
PAGE = "page"
|
||||
PANEL = "panel"
|
||||
PLUGIN = "plugin"
|
||||
STORY = "story"
|
||||
|
||||
FAVICON = "favicon.ico"
|
||||
PROTO_JS = "proto.js"
|
||||
|
@ -38,7 +38,7 @@ func _cmd_file(m *ice.Message, arg ...string) bool {
|
||||
web.RenderCmd(m, "can.parse", m.Cmdx(nfs.CAT, p))
|
||||
|
||||
default:
|
||||
if p = strings.TrimPrefix(p, ice.SRC+ice.PS); kit.FileExists(path.Join(ice.SRC, p)) {
|
||||
if p = strings.TrimPrefix(p, ice.SRC+ice.PS); nfs.ExistsFile(m, path.Join(ice.SRC, p)) {
|
||||
if msg := m.Cmd(mdb.RENDER, kit.Ext(p)); msg.Length() > 0 {
|
||||
m.Cmdy(mdb.RENDER, kit.Ext(p), p, ice.SRC+ice.PS).RenderResult()
|
||||
break
|
||||
|
@ -131,7 +131,7 @@ body.{{.Option "topic"}} fieldset.panel.Header>div.output div:hover { background
|
||||
})
|
||||
m.PushAction("choose", "form", mdb.REMOVE)
|
||||
} else {
|
||||
if p := "src/website/topic/" + arg[0]; kit.FileExists(p) {
|
||||
if p := "src/website/topic/" + arg[0]; nfs.ExistsFile(m, p) {
|
||||
m.Cmdy(nfs.CAT, p)
|
||||
} else {
|
||||
m.Tables(func(value ice.Maps) {
|
||||
@ -141,7 +141,7 @@ body.{{.Option "topic"}} fieldset.panel.Header>div.output div:hover { background
|
||||
}
|
||||
}},
|
||||
"/topic/": {Name: "/topic/", Help: "主题", Hand: func(m *ice.Message, arg ...string) {
|
||||
if p := "src/website/topic/" + arg[0]; kit.FileExists(p) {
|
||||
if p := "src/website/topic/" + arg[0]; nfs.ExistsFile(m, p) {
|
||||
m.RenderDownload(p)
|
||||
return
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ func _binpack_ctx(m *ice.Message, w io.Writer) {
|
||||
_binpack_dir(m, w, ice.SRC)
|
||||
}
|
||||
func _binpack_all(m *ice.Message) {
|
||||
nfs.OptionFiles(m, nfs.DiskFile)
|
||||
if w, p, e := nfs.CreateFile(m, ice.SRC_BINPACK_GO); m.Assert(e) {
|
||||
defer w.Close()
|
||||
defer m.Echo(p)
|
||||
@ -79,6 +80,7 @@ func init() {
|
||||
defer fmt.Fprintln(w, `}`)
|
||||
|
||||
defer fmt.Fprintln(w, `
|
||||
nfs.PackFile.RemoveAll(ice.SRC)
|
||||
for k, v := range pack {
|
||||
if b, e := base64.StdEncoding.DecodeString(v); e == nil {
|
||||
nfs.PackFile.WriteFile(k, b)
|
||||
|
@ -12,7 +12,7 @@ import (
|
||||
)
|
||||
|
||||
func _c_tags(m *ice.Message, key string) {
|
||||
if !kit.FileExists(path.Join(m.Option(cli.CMD_DIR), TAGS)) {
|
||||
if !nfs.ExistsFile(m, path.Join(m.Option(cli.CMD_DIR), TAGS)) {
|
||||
m.Cmd(cli.SYSTEM, "ctags", "-R", "-f", TAGS, nfs.PWD)
|
||||
}
|
||||
_go_tags(m, key)
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
)
|
||||
|
||||
func _go_tags(m *ice.Message, key string) {
|
||||
if s, e := os.Stat(path.Join(m.Option(cli.CMD_DIR), TAGS)); os.IsNotExist(e) || s.ModTime().Before(time.Now().Add(kit.Duration("-72h"))) {
|
||||
if s, e := nfs.StatFile(m, path.Join(m.Option(cli.CMD_DIR), TAGS)); os.IsNotExist(e) || s.ModTime().Before(time.Now().Add(kit.Duration("-72h"))) {
|
||||
m.Cmd(cli.SYSTEM, "gotags", "-R", "-f", TAGS, nfs.PWD)
|
||||
}
|
||||
|
||||
@ -36,7 +36,7 @@ func _go_tags(m *ice.Message, key string) {
|
||||
text := strings.TrimSuffix(strings.TrimPrefix(ls[0], "/^"), "$/")
|
||||
line := kit.Int(text)
|
||||
|
||||
f, e := os.Open(path.Join(m.Option(cli.CMD_DIR), file))
|
||||
f, e := nfs.OpenFile(m, path.Join(m.Option(cli.CMD_DIR), file))
|
||||
m.Assert(e)
|
||||
defer f.Close()
|
||||
|
||||
|
@ -32,8 +32,8 @@ func _install_download(m *ice.Message) {
|
||||
file := path.Join(kit.Select(ice.USR_INSTALL, m.Option(nfs.PATH)), name)
|
||||
|
||||
if nfs.ExistsFile(m, file) {
|
||||
web.ToastSuccess(m)
|
||||
m.Cmdy(nfs.DIR, file)
|
||||
web.ToastSuccess(m)
|
||||
return // 文件存在
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,7 @@ func _publish_file(m *ice.Message, file string, arg ...string) string {
|
||||
|
||||
} else if s, e := nfs.StatFile(m, file); m.Assert(e) && s.IsDir() {
|
||||
file = m.Cmdx(nfs.TAR, mdb.IMPORT, path.Base(file), file)
|
||||
defer func() { os.Remove(file) }()
|
||||
defer func() { nfs.Remove(m, file) }()
|
||||
}
|
||||
|
||||
// 发布文件
|
||||
@ -43,7 +43,7 @@ func _publish_bin_list(m *ice.Message, dir string) {
|
||||
p := m.Option(cli.CMD_DIR, dir)
|
||||
for _, ls := range strings.Split(strings.TrimSpace(m.Cmd(cli.SYSTEM, "bash", "-c", "ls |xargs file |grep executable").Append(cli.CMD_OUT)), ice.NL) {
|
||||
if file := strings.TrimSpace(strings.Split(ls, ":")[0]); file != "" {
|
||||
if s, e := os.Stat(path.Join(p, file)); e == nil {
|
||||
if s, e := nfs.StatFile(m, path.Join(p, file)); e == nil {
|
||||
m.Push(mdb.TIME, s.ModTime())
|
||||
m.Push(nfs.SIZE, kit.FmtSize(s.Size()))
|
||||
m.Push(nfs.FILE, file)
|
||||
|
@ -31,6 +31,12 @@ func init() {
|
||||
Index.Merge(&ice.Context{Commands: ice.Commands{
|
||||
PY: {Name: "py path auto", Help: "脚本", Actions: ice.MergeActions(ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Go(func() {
|
||||
m.Sleep300ms() // after runtime init
|
||||
cli.IsAlpine(m, "python", "python2")
|
||||
cli.IsAlpine(m, "python2")
|
||||
cli.IsAlpine(m, "python3")
|
||||
})
|
||||
m.Cmd(mdb.ENGINE, mdb.CREATE, PY, m.PrefixKey())
|
||||
m.Cmd(mdb.RENDER, mdb.CREATE, PY, m.PrefixKey())
|
||||
}},
|
||||
|
@ -26,7 +26,7 @@ chapter "hi"
|
||||
print "hello world"
|
||||
`,
|
||||
nfs.JS, `
|
||||
Volcanos("onimport", {help: "导入数据", _init: function(can, msg) {
|
||||
Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg) {
|
||||
msg.Echo("hello world")
|
||||
msg.Dump(can)
|
||||
}})
|
||||
|
@ -29,7 +29,9 @@ func _xterm_get(m *ice.Message, h string, must bool) *os.File {
|
||||
return nil
|
||||
}
|
||||
|
||||
cmd := exec.Command(cli.SystemFind(m, kit.Select("sh", m.Option(mdb.TYPE))))
|
||||
ls := kit.Split(kit.Select("sh", m.Option(mdb.TYPE)))
|
||||
m.Debug("what %v", kit.Format(ls))
|
||||
cmd := exec.Command(cli.SystemFind(m, ls[0]), ls[1:]...)
|
||||
cmd.Env = append(os.Environ(), "TERM=xterm")
|
||||
m.Option(mdb.HASH, h)
|
||||
|
||||
|
@ -66,7 +66,7 @@ func _field_show(m *ice.Message, name, text string, arg ...string) {
|
||||
meta[arg[i]] = arg[i+1]
|
||||
|
||||
case SPARK:
|
||||
if arg[i+1][0] == '@' && kit.FileExists(arg[i+1][1:]) {
|
||||
if arg[i+1][0] == '@' && nfs.ExistsFile(m, arg[i+1][1:]) {
|
||||
msg.Cmdy(nfs.CAT, arg[i+1][1:])
|
||||
} else {
|
||||
msg.Echo(strings.TrimSpace(arg[i+1]))
|
||||
|
@ -74,11 +74,12 @@ func init() {
|
||||
}},
|
||||
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(nfs.DIR, "src/", kit.Dict(nfs.DIR_DEEP, ice.TRUE, nfs.DIR_REG, ".*\\.shy"), nfs.DIR_CLI_FIELDS)
|
||||
m.Cmdy(nfs.DIR, "src/help/", kit.Dict(nfs.DIR_DEEP, ice.TRUE, nfs.DIR_REG, ".*\\.shy"), nfs.DIR_CLI_FIELDS)
|
||||
for _, p := range []string{"src/", "src/help/", "usr/icebergs/"} {
|
||||
m.Cmdy(nfs.DIR, p, kit.Dict(nfs.DIR_DEEP, ice.TRUE, nfs.DIR_REG, ".*\\.shy"), nfs.DIR_CLI_FIELDS)
|
||||
}
|
||||
}},
|
||||
"story": {Name: "story", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(arg[0], ctx.ACTION, ice.RUN, arg[2:])
|
||||
ice.STORY: {Name: "story", Help: "运行", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(arg[0], ice.RUN, arg[2:])
|
||||
}},
|
||||
ice.PLAY: {Name: "play", Help: "演示"},
|
||||
}, ctx.CmdAction(), mdb.HashAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -87,7 +88,7 @@ func init() {
|
||||
arg = append(arg, "src/")
|
||||
}
|
||||
if m.Option(nfs.DIR_DEEP, ice.TRUE); !_wiki_list(m, m.CommandKey(), arg...) {
|
||||
if !kit.FileExists(arg[0]) && kit.FileExists(path.Join("src", arg[0])) {
|
||||
if !nfs.ExistsFile(m, arg[0]) && nfs.ExistsFile(m, path.Join("src", arg[0])) {
|
||||
arg[0] = path.Join("src/", arg[0])
|
||||
}
|
||||
ctx.DisplayLocal(m, "")
|
||||
|
1
go.mod
1
go.mod
@ -5,6 +5,7 @@ go 1.11
|
||||
require (
|
||||
shylinux.com/x/creackpty v0.0.1
|
||||
shylinux.com/x/go-qrcode v0.0.1
|
||||
shylinux.com/x/ice v1.0.7
|
||||
shylinux.com/x/toolkits v0.6.6
|
||||
shylinux.com/x/websocket v0.0.1
|
||||
)
|
||||
|
4
go.sum
4
go.sum
@ -2,6 +2,10 @@ shylinux.com/x/creackpty v0.0.1 h1:o+qDE39jFsHLZB9BRAm0EI6qScjw5PuvdkROqhTcupM=
|
||||
shylinux.com/x/creackpty v0.0.1/go.mod h1:d7DnPv3oGc23WlzrN8hW7p88wNLPAO/XG4ICVEq96i0=
|
||||
shylinux.com/x/go-qrcode v0.0.1 h1:/eOGqMj1qtgs9Ymd12zTUa1gcJZs9S92kj2lb0QzKsE=
|
||||
shylinux.com/x/go-qrcode v0.0.1/go.mod h1:KAbtU+KwiiABMZ/CJ0zh9PI2AX82Uf9rRYcQ4ODm4po=
|
||||
shylinux.com/x/ice v1.0.7 h1:prm2IiOJ7nevt9pSmTEXGHq/Vjeo1n+gDfo54G5OPtI=
|
||||
shylinux.com/x/ice v1.0.7/go.mod h1:9ErxoqjwAzbcOkJAD7+OPuRrQ12/kduO7arHipUCry0=
|
||||
shylinux.com/x/icebergs v1.3.0/go.mod h1:HhX/7lagVsvO80yYbfpf7FW4ddLOFv8kUwjBr8STRUQ=
|
||||
shylinux.com/x/toolkits v0.6.5/go.mod h1:8LbYHe7oxBIqb6s4MSOD+4d28QvPdvkyCVtwB/JW7AA=
|
||||
shylinux.com/x/toolkits v0.6.6 h1:OcuGs4PLj9qynf14o8UE1wndT3+tnum0wpOo0KFq/tM=
|
||||
shylinux.com/x/toolkits v0.6.6/go.mod h1:8LbYHe7oxBIqb6s4MSOD+4d28QvPdvkyCVtwB/JW7AA=
|
||||
shylinux.com/x/websocket v0.0.1 h1:OBc21DxqsGlQ2+Pz76xqLyDNo1LV+PUUqfWi+1PZPDE=
|
||||
|
2
logs.go
2
logs.go
@ -195,7 +195,7 @@ func (m *Message) FormatStack(s, n int) string {
|
||||
name := kit.Slice(kit.Split(frame.Function, PS, PS), -1)[0]
|
||||
|
||||
switch ls := kit.Split(name, PT, PT); kit.Select("", ls, 0) {
|
||||
// case "reflect", "runtime", "http", "task", "icebergs":
|
||||
case "reflect", "runtime", "http", "task", "icebergs":
|
||||
default:
|
||||
list = append(list, kit.Format("%s:%d\t%s", file, frame.Line, name))
|
||||
}
|
||||
|
6
meta.go
6
meta.go
@ -159,7 +159,11 @@ func (m *Message) Push(key string, value Any, arg ...Any) *Message {
|
||||
// 追加数据
|
||||
switch v := kit.Format(v); key {
|
||||
case FIELDS_DETAIL:
|
||||
m.Add(MSG_APPEND, KEY, k)
|
||||
switch k {
|
||||
case "_target":
|
||||
continue
|
||||
}
|
||||
m.Add(MSG_APPEND, KEY, strings.TrimPrefix(k, "extra."))
|
||||
m.Add(MSG_APPEND, VALUE, v)
|
||||
default:
|
||||
m.Add(MSG_APPEND, k, v)
|
||||
|
@ -1,7 +1,6 @@
|
||||
package alpha
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
@ -34,7 +33,7 @@ func (a alpha) Load(m *ice.Message, arg ...string) {
|
||||
name := m.Option(mdb.NAME)
|
||||
// 清空数据
|
||||
meta := m.Confm(m.PrefixKey(), mdb.META)
|
||||
m.Assert(os.RemoveAll(path.Join(kit.Format(meta[mdb.STORE]), name)))
|
||||
m.Assert(nfs.RemoveAll(m.Message, path.Join(kit.Format(meta[mdb.STORE]), name)))
|
||||
m.Conf(m.PrefixKey(), name, "")
|
||||
|
||||
// 缓存配置
|
||||
|
@ -1,8 +1,6 @@
|
||||
package bash
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
@ -39,7 +37,7 @@ func init() {
|
||||
}},
|
||||
mdb.PRUNES: {Name: "prunes before@date", Help: "清理", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.HashPrunes(m, func(value ice.Maps) bool {
|
||||
os.RemoveAll(value[TO])
|
||||
nfs.RemoveAll(m, value[TO])
|
||||
return true
|
||||
})
|
||||
}},
|
||||
|
@ -1,15 +1,18 @@
|
||||
chapter "codeserver"
|
||||
section "code-server"
|
||||
refer `
|
||||
https://coder.com/
|
||||
https://github.com/coder/code-server/
|
||||
https://github.com/microsoft/vscode
|
||||
https://code.visualstudio.com/
|
||||
https://geek-docs.com/vscode/vscode-tutorials/what-is-vscode.html
|
||||
官网 https://coder.com/
|
||||
源码 https://github.com/coder/code-server/
|
||||
`
|
||||
|
||||
spark shell `
|
||||
wget https://github.com/coder/code-server/releases/download/v4.4.0/code-server-4.4.0-linux-amd64.tar.gz
|
||||
tar xvf code-server-4.4.0-linux-amd64.tar.gz
|
||||
cd code-server-4.4.0-linux-amd64
|
||||
tar xvf code-server-4.4.0-linux-amd64.tar.gz && cd code-server-4.4.0-linux-amd64
|
||||
./bin/code-server
|
||||
`
|
||||
field web.code.coder.server
|
||||
|
||||
refer `
|
||||
官网 https://code.visualstudio.com/
|
||||
源码 https://github.com/microsoft/vscode
|
||||
入门 https://geek-docs.com/vscode/vscode-tutorials/what-is-vscode.html
|
||||
`
|
||||
|
@ -1,7 +1,6 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
@ -23,7 +22,7 @@ func _repos_path(name string) string {
|
||||
return kit.Select(path.Join(ice.USR, name)+ice.PS, nfs.PWD, name == path.Base(kit.Pwd()))
|
||||
}
|
||||
func _repos_insert(m *ice.Message, name string, dir string) {
|
||||
if s, e := os.Stat(m.Option(cli.CMD_DIR, path.Join(dir, ".git"))); e == nil && s.IsDir() {
|
||||
if s, e := nfs.StatFile(m, m.Option(cli.CMD_DIR, path.Join(dir, ".git"))); e == nil && s.IsDir() {
|
||||
ls := strings.SplitN(strings.Trim(m.Cmdx(cli.SYSTEM, GIT, "log", "-n1", `--pretty=format:"%ad %s"`, "--date=iso"), `"`), ice.SP, 4)
|
||||
mdb.Rich(m, REPOS, nil, kit.Data(mdb.NAME, name, nfs.PATH, dir,
|
||||
COMMIT, kit.Select("", ls, 3), mdb.TIME, strings.Join(ls[:2], ice.SP),
|
||||
@ -71,12 +70,12 @@ func init() {
|
||||
// }
|
||||
|
||||
_repos_insert(m, m.Option(mdb.NAME), m.Option(nfs.PATH))
|
||||
if s, e := os.Stat(path.Join(m.Option(nfs.PATH), ".git")); e == nil && s.IsDir() {
|
||||
if s, e := nfs.StatFile(m, path.Join(m.Option(nfs.PATH), ".git")); e == nil && s.IsDir() {
|
||||
return
|
||||
}
|
||||
|
||||
// 下载仓库
|
||||
if s, e := os.Stat(m.Option(nfs.PATH)); e == nil && s.IsDir() {
|
||||
if s, e := nfs.StatFile(m, m.Option(nfs.PATH)); e == nil && s.IsDir() {
|
||||
m.Option(cli.CMD_DIR, m.Option(nfs.PATH))
|
||||
m.Cmd(cli.SYSTEM, GIT, INIT)
|
||||
m.Cmd(cli.SYSTEM, GIT, REMOTE, ADD, ORIGIN, m.Option(REPOS))
|
||||
|
@ -155,7 +155,7 @@ func init() {
|
||||
web.RenderStatus(m.W, 401, err.Error())
|
||||
return // 没有权限
|
||||
}
|
||||
if !kit.FileExists(path.Join(repos)) {
|
||||
if !nfs.ExistsFile(m, path.Join(repos)) {
|
||||
m.Cmd(cli.SYSTEM, GIT, INIT, "--bare", repos) // 创建仓库
|
||||
m.Logs(mdb.CREATE, REPOS, repos)
|
||||
}
|
||||
@ -164,7 +164,7 @@ func init() {
|
||||
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", web.MergeURL2(m, "/x/")+arg[0])
|
||||
}
|
||||
if !kit.FileExists(path.Join(repos)) {
|
||||
if !nfs.ExistsFile(m, path.Join(repos)) {
|
||||
web.RenderStatus(m.W, 404, kit.Format("not found: %s", arg[0]))
|
||||
return
|
||||
}
|
||||
|
@ -1,7 +1,6 @@
|
||||
package git
|
||||
|
||||
import (
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
"sync"
|
||||
@ -88,10 +87,10 @@ func init() {
|
||||
}},
|
||||
"_sum": {Name: "_sum [path] [total] [count|date] args...", Help: "统计量", Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 0 {
|
||||
if s, e := os.Stat(path.Join(arg[0], ".git")); e == nil && s.IsDir() {
|
||||
if s, e := nfs.StatFile(m, path.Join(arg[0], ".git")); e == nil && s.IsDir() {
|
||||
m.Option(cli.CMD_DIR, arg[0])
|
||||
arg = arg[1:]
|
||||
} else if s, e := os.Stat(path.Join(arg[0], "refs")); e == nil && s.IsDir() {
|
||||
} else if s, e := nfs.StatFile(m, path.Join(arg[0], "refs")); e == nil && s.IsDir() {
|
||||
m.Option(cli.CMD_DIR, arg[0])
|
||||
arg = arg[1:]
|
||||
}
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"bytes"
|
||||
"encoding/csv"
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
@ -34,12 +33,12 @@ type input struct {
|
||||
}
|
||||
|
||||
func (i input) Load(m *ice.Message, arg ...string) {
|
||||
if f, e := os.Open(m.Option(nfs.FILE)); m.Assert(e) {
|
||||
if f, e := nfs.OpenFile(m.Message, m.Option(nfs.FILE)); m.Assert(e) {
|
||||
defer f.Close()
|
||||
|
||||
// 清空数据
|
||||
lib := kit.Select(path.Base(m.Option(nfs.FILE)), m.Option(mdb.ZONE))
|
||||
m.Assert(os.RemoveAll(path.Join(m.Config(mdb.STORE), lib)))
|
||||
m.Assert(nfs.RemoveAll(m.Message, path.Join(m.Config(mdb.STORE), lib)))
|
||||
m.Cmd(mdb.DELETE, m.PrefixKey(), "", mdb.HASH, mdb.ZONE, lib)
|
||||
prefix := kit.Keys(mdb.HASH, mdb.Rich(m.Message, m.PrefixKey(), "", kit.Data(
|
||||
mdb.STORE, path.Join(m.Config(mdb.STORE), lib),
|
||||
|
@ -10,27 +10,40 @@ import (
|
||||
)
|
||||
|
||||
const (
|
||||
MVN = "mvn"
|
||||
JAVA = "java"
|
||||
JAVAC = "javac"
|
||||
)
|
||||
|
||||
type server struct {
|
||||
type compile struct {
|
||||
ice.Code
|
||||
regexp string `data:".*.java"`
|
||||
linux string `data:"https://mirrors.tencent.com/repository/generic/konajdk/8/0/10/linux-x86_64/b1/TencentKona8.0.10.b1_jdk_linux-x86_64_8u332.tar.gz"`
|
||||
list string `name:"list path auto listScript order install" help:"编译执行"`
|
||||
list string `name:"list path auto listScript order install" help:"编译器"`
|
||||
}
|
||||
|
||||
func (s server) Order(m *ice.Message) {
|
||||
func (s compile) Init(m *ice.Message) {
|
||||
m.Go(func() {
|
||||
m.Sleep300ms() // after runtime init
|
||||
cli.IsAlpine(m.Message, JAVA, "openjdk8")
|
||||
cli.IsAlpine(m.Message, JAVAC, "openjdk8")
|
||||
cli.IsAlpine(m.Message, MVN, "maven openjdk8")
|
||||
|
||||
cli.IsCentos(m.Message, JAVA, "java-1.8.0-openjdk-devel.x86_64")
|
||||
cli.IsCentos(m.Message, JAVAC, "java-1.8.0-openjdk-devel.x86_64")
|
||||
cli.IsCentos(m.Message, MVN, "maven java-1.8.0-openjdk-devel.x86_64")
|
||||
})
|
||||
}
|
||||
func (s compile) Order(m *ice.Message) {
|
||||
s.Code.Order(m, "", ice.BIN)
|
||||
}
|
||||
func (s server) List(m *ice.Message, arg ...string) {
|
||||
func (s compile) List(m *ice.Message, arg ...string) {
|
||||
s.Code.Source(m, "", arg...)
|
||||
}
|
||||
func (s server) RunScript(m *ice.Message) {
|
||||
func (s compile) RunScript(m *ice.Message) {
|
||||
if s.Code.System(m, nfs.PWD, JAVAC, "-d", ice.BIN, m.Option(nfs.PATH)); cli.IsSuccess(m.Message) {
|
||||
s.Code.System(m, nfs.PWD, JAVA, "-cp", kit.Path(ice.BIN), strings.TrimPrefix(strings.TrimSuffix(m.Option(nfs.PATH), ".java"), "src/"))
|
||||
}
|
||||
}
|
||||
|
||||
func init() { ice.CodeCtxCmd(server{}) }
|
||||
func init() { ice.CodeCtxCmd(compile{}) }
|
9
misc/java/compile.shy
Normal file
9
misc/java/compile.shy
Normal file
@ -0,0 +1,9 @@
|
||||
section "java"
|
||||
refer `
|
||||
官网 https://www.java.com/
|
||||
文档 https://docs.oracle.com/javase/tutorial/
|
||||
源码 https://github.com/openjdk/jdk
|
||||
开源 https://openjdk.org/
|
||||
`
|
||||
field web.code.java.compile
|
||||
|
@ -1,9 +1,10 @@
|
||||
section "spring"
|
||||
refer `
|
||||
官网 https://spring.io/projects/spring-boot
|
||||
源码 https://github.com/spring-projects/spring-boot
|
||||
入门 https://spring.io/quickstart
|
||||
向导 https://start.spring.io/
|
||||
参数 https://docs.spring.io/spring-boot/docs/current/reference/html/application-properties.html
|
||||
接口 https://spring.io/guides/gs/rest-service/
|
||||
数据 https://spring.io/guides/gs/accessing-data-mysql/
|
||||
`
|
||||
`
|
||||
|
37
misc/node/compile.go
Normal file
37
misc/node/compile.go
Normal file
@ -0,0 +1,37 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
)
|
||||
|
||||
const (
|
||||
NPM = "npm"
|
||||
NODE = "node"
|
||||
)
|
||||
|
||||
type compile struct {
|
||||
ice.Code
|
||||
regexp string `data:".*.js"`
|
||||
linux string `data:"https://mirrors.tencent.com/nodejs-release/v16.15.1/node-v16.15.1-linux-x64.tar.xz"`
|
||||
list string `name:"list path auto xterm listScript order install" help:"编译器"`
|
||||
}
|
||||
|
||||
func (s compile) Init(m *ice.Message) {
|
||||
m.Go(func() {
|
||||
m.Sleep300ms() // after runtime init
|
||||
cli.IsAlpine(m.Message, NPM)
|
||||
cli.IsAlpine(m.Message, NODE, "nodejs")
|
||||
})
|
||||
}
|
||||
func (s compile) Order(m *ice.Message) {
|
||||
s.Code.Order(m, "", ice.BIN)
|
||||
}
|
||||
func (s compile) Xterm(m *ice.Message, arg ...string) {
|
||||
s.Code.Xterm(m, NODE, arg...)
|
||||
}
|
||||
func (s compile) List(m *ice.Message, arg ...string) {
|
||||
s.Code.Source(m, "", arg...)
|
||||
}
|
||||
|
||||
func init() { ice.CodeCtxCmd(compile{}) }
|
8
misc/node/compile.shy
Normal file
8
misc/node/compile.shy
Normal file
@ -0,0 +1,8 @@
|
||||
section "node"
|
||||
refer `
|
||||
官网 https://nodejs.org/
|
||||
文档 https://nodejs.org/docs/latest-v6.x/api/
|
||||
源码 https://github.com/nodejs/node
|
||||
`
|
||||
field web.code.node.compile
|
||||
|
@ -1,22 +0,0 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
)
|
||||
|
||||
type server struct {
|
||||
ice.Code
|
||||
command string `data:"node"`
|
||||
regexp string `data:".*.js"`
|
||||
linux string `data:"https://mirrors.tencent.com/nodejs-release/v16.15.1/node-v16.15.1-linux-x64.tar.xz"`
|
||||
list string `name:"list path auto listScript order install" help:"编译执行"`
|
||||
}
|
||||
|
||||
func (s server) Order(m *ice.Message) {
|
||||
s.Code.Order(m, "", ice.BIN)
|
||||
}
|
||||
func (s server) List(m *ice.Message, arg ...string) {
|
||||
s.Code.Source(m, "", arg...)
|
||||
}
|
||||
|
||||
func init() { ice.CodeCtxCmd(server{}) }
|
@ -1,5 +1,6 @@
|
||||
section "vue"
|
||||
refer `
|
||||
官网 https://vuejs.org/
|
||||
源码 https://github.com/vuejs/vue
|
||||
入门 https://vuejs.org/guide/quick-start.html
|
||||
`
|
||||
`
|
||||
|
@ -45,17 +45,17 @@ func _ssh_open(m *ice.Message, arg ...string) {
|
||||
}
|
||||
func _ssh_dial(m *ice.Message, cb func(net.Conn), arg ...string) {
|
||||
p := path.Join(kit.Env(cli.HOME), ".ssh/", fmt.Sprintf("%s@%s:%s", m.Option(aaa.USERNAME), m.Option(tcp.HOST), m.Option(tcp.PORT)))
|
||||
if kit.FileExists(p) {
|
||||
if nfs.FileExists(m, p) {
|
||||
if c, e := net.Dial("unix", p); e == nil {
|
||||
cb(c) // 会话连接
|
||||
return
|
||||
}
|
||||
os.Remove(p)
|
||||
nfs.Remove(m, p)
|
||||
}
|
||||
|
||||
_ssh_conn(m, func(client *ssh.Client) {
|
||||
if l, e := net.Listen("unix", p); m.Assert(e) {
|
||||
defer func() { os.Remove(p) }()
|
||||
defer func() { nfs.Remove(m, p) }()
|
||||
defer l.Close()
|
||||
|
||||
m.Go(func() {
|
||||
|
@ -79,18 +79,14 @@ func init() {
|
||||
|
||||
} else { // 创建会话
|
||||
m.Option(cli.CMD_DIR, path.Join(ice.USR_LOCAL_WORK, m.Option(mdb.NAME)))
|
||||
ls := kit.Split(m.Option(mdb.NAME), "-_")
|
||||
ls := kit.Split(strings.TrimSuffix(m.Option(mdb.NAME), "-story"), "-")
|
||||
name := ls[len(ls)-1]
|
||||
|
||||
m.Cmdy(cli.SYSTEM, TMUX, "new-session", "-ds", m.Option(mdb.NAME), "-n", name)
|
||||
name = _tmux_key(m.Option(mdb.NAME), ls[len(ls)-1])
|
||||
|
||||
m.Cmdy(cli.SYSTEM, TMUX, "split-window", "-t", kit.Keys(name, "1"), "-p", "20")
|
||||
m.Cmdy(cli.SYSTEM, TMUX, "split-window", "-t", kit.Keys(name, "2"), "-h")
|
||||
|
||||
m.Cmd(cli.SYSTEM, TMUX, "send-keys", "-t", kit.Keys(name, "3"), "ish_miss_log", "Enter")
|
||||
// m.Cmd(cli.SYSTEM, TMUX, "send-keys", "-t", kit.Keys(name, "2"), "ish_miss_space", "Enter")
|
||||
m.Cmd(cli.SYSTEM, TMUX, "send-keys", "-t", kit.Keys(name, "2"), "ish_miss_space")
|
||||
m.Cmd(cli.SYSTEM, TMUX, "split-window", "-t", kit.Keys(name, "1"), "-p", "40")
|
||||
m.Cmd(cli.SYSTEM, TMUX, "send-keys", "-t", kit.Keys(name, "2"), "ish_miss_log", "Enter")
|
||||
m.Cmd(cli.SYSTEM, TMUX, "send-keys", "-t", kit.Keys(name, "1"), "vi etc/miss.sh", "Enter")
|
||||
|
||||
m.Cmdy(cli.SYSTEM, TMUX, "link-window", "-s", name, "-t", "miss:")
|
||||
|
Loading…
x
Reference in New Issue
Block a user