forked from x/icebergs
opt some
This commit is contained in:
parent
dd83d6040d
commit
3efdc8b7dc
@ -5,7 +5,9 @@ import (
|
||||
"strings"
|
||||
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
@ -24,19 +26,15 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
MIRRORS: {Name: "mirrors cli 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
|
||||
m.Conf(m.Prefix(MIRRORS), kit.Keys(mdb.HASH), "")
|
||||
IsAlpine(m, "curl")
|
||||
IsAlpine(m, "make")
|
||||
IsAlpine(m, "gcc")
|
||||
IsAlpine(m, "vim")
|
||||
IsAlpine(m, "tmux")
|
||||
|
||||
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))
|
||||
}
|
||||
})
|
||||
m.Conf(m.Prefix(MIRRORS), kit.Keys(mdb.HASH), "")
|
||||
IsAlpine(m, "curl")
|
||||
IsAlpine(m, "make")
|
||||
IsAlpine(m, "gcc")
|
||||
IsAlpine(m, "vim")
|
||||
IsAlpine(m, "tmux")
|
||||
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))
|
||||
}
|
||||
}},
|
||||
mdb.INSERT: {Name: "insert cli osid cmd", Help: "添加"},
|
||||
CMD: {Name: "cmd cli osid", Help: "安装", Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -54,17 +52,37 @@ func init() {
|
||||
})
|
||||
}
|
||||
|
||||
func osid(m *ice.Message, sys string) bool {
|
||||
osid := runtime.GOOS
|
||||
m.Option(ice.MSG_USERROLE, aaa.ROOT)
|
||||
m.Cmd(nfs.CAT, "/etc/os-release", func(text string) {
|
||||
if ls := kit.Split(text, "="); len(ls) > 1 {
|
||||
switch ls[0] {
|
||||
case "ID", "ID_LIKE":
|
||||
osid = strings.TrimSpace(ls[1] + ice.SP + osid)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if strings.Contains(osid, sys) {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
func IsAlpine(m *ice.Message, arg ...string) bool {
|
||||
if strings.Contains(m.Conf(RUNTIME, kit.Keys(HOST, OSID)), ALPINE) {
|
||||
if osid(m, ALPINE) {
|
||||
if len(arg) > 0 {
|
||||
m.Cmd(mdb.INSERT, kit.Keys(CLI, MIRRORS), "", mdb.ZONE, arg[0], OSID, ALPINE, CMD, "system apk add "+kit.Select(arg[0], arg, 1))
|
||||
m.Go(func() {
|
||||
m.Sleep300ms()
|
||||
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 osid(m, ALPINE) {
|
||||
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))
|
||||
}
|
||||
@ -73,7 +91,7 @@ func IsCentos(m *ice.Message, arg ...string) bool {
|
||||
return false
|
||||
}
|
||||
func IsUbuntu(m *ice.Message, arg ...string) bool {
|
||||
if strings.Contains(m.Conf(RUNTIME, kit.Keys(HOST, OSID)), UBUNTU) {
|
||||
if osid(m, ALPINE) {
|
||||
if len(arg) > 0 {
|
||||
m.Cmd(mdb.INSERT, kit.Keys(CLI, MIRRORS), "", mdb.ZONE, arg[0], OSID, UBUNTU, CMD, "yum install -y "+kit.Select(arg[0], arg, 1))
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ func init() {
|
||||
arg = append(arg, "")
|
||||
}
|
||||
m.Option(CMD_ENV, "COLUMNS", kit.Int(kit.Select("1920", m.Option("width")))/12)
|
||||
m.Cmdy(SYSTEM, "sh", "-c", kit.Format("man %s %s|col -b", kit.Select("", arg[1], arg[1] != "1"), arg[0]))
|
||||
m.Echo(SystemCmds(m, "man %s %s|col -b", kit.Select("", arg[1], arg[1] != "1"), arg[0]))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) == 0 {
|
||||
@ -204,3 +204,9 @@ func SystemFind(m Message, bin string, dir ...string) string {
|
||||
dir = append(dir, strings.Split(kit.Env(PATH), ice.DF)...)
|
||||
return _system_find(m, bin, dir...)
|
||||
}
|
||||
func SystemExec(m *ice.Message, arg ...string) string {
|
||||
return strings.TrimSpace(m.Cmdx(SYSTEM, arg))
|
||||
}
|
||||
func SystemCmds(m *ice.Message, cmds string, args ...ice.Any) string {
|
||||
return strings.TrimRight(m.Cmdx(SYSTEM, "sh", "-c", kit.Format(cmds, args...), ice.Option{CMD_OUTPUT, ""}), ice.NL)
|
||||
}
|
||||
|
@ -205,3 +205,13 @@ func Dir(m *ice.Message, sort string) *ice.Message {
|
||||
m.Copy(m.Cmd(DIR, PWD).Sort(sort))
|
||||
return m
|
||||
}
|
||||
func DirDeepAll(m *ice.Message, root, dir string, cb func(ice.Maps), arg ...string) *ice.Message {
|
||||
m.Option(DIR_TYPE, CAT)
|
||||
m.Option(DIR_ROOT, root)
|
||||
m.Option(DIR_DEEP, ice.TRUE)
|
||||
if msg := m.Cmd(DIR, dir, arg).Sort(PATH).Tables(cb); cb == nil {
|
||||
return m.Copy(msg)
|
||||
} else {
|
||||
return msg
|
||||
}
|
||||
}
|
||||
|
@ -414,3 +414,6 @@ func SpidePost(m *ice.Message, arg ...ice.Any) ice.Any {
|
||||
func SpideDelete(m *ice.Message, arg ...ice.Any) ice.Any {
|
||||
return kit.UnMarshal(m.Cmdx(SPIDE_DELETE, arg))
|
||||
}
|
||||
func SpideSave(m *ice.Message, file, link string, cb func(int, int, int)) *ice.Message {
|
||||
return m.Cmd("web.spide", ice.DEV, SPIDE_SAVE, file, SPIDE_GET, link, cb)
|
||||
}
|
||||
|
14
conf.go
14
conf.go
@ -96,13 +96,13 @@ const ( // DIR
|
||||
PLUGIN = "plugin"
|
||||
STORY = "story"
|
||||
|
||||
FAVICON = "favicon.ico"
|
||||
PROTO_JS = "proto.js"
|
||||
FRAME_JS = "frame.js"
|
||||
INDEX_JS = "index.js"
|
||||
INDEX_SH = "index.sh"
|
||||
INDEX_IML = "index.iml"
|
||||
TUTOR_SHY = "tutor.shy"
|
||||
FAVICON_ICO = "favicon.ico"
|
||||
PROTO_JS = "proto.js"
|
||||
FRAME_JS = "frame.js"
|
||||
INDEX_JS = "index.js"
|
||||
INDEX_SH = "index.sh"
|
||||
INDEX_IML = "index.iml"
|
||||
TUTOR_SHY = "tutor.shy"
|
||||
|
||||
PLUGIN_INPUT = "/plugin/input"
|
||||
PLUGIN_STORY = "/plugin/story"
|
||||
|
@ -5,6 +5,7 @@ import (
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
const IFRAME = "iframe"
|
||||
@ -12,7 +13,11 @@ const IFRAME = "iframe"
|
||||
func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
IFRAME: {Name: "iframe hash auto", Help: "浏览器", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.CREATE: {Name: "create link name type", Help: "创建"},
|
||||
mdb.CREATE: {Name: "create link name type", Help: "创建", Hand: func(m *ice.Message, arg ...string) {
|
||||
u := kit.ParseURL(m.Option(mdb.LINK))
|
||||
m.OptionDefault(mdb.NAME, u.Host)
|
||||
mdb.HashCreate(m, m.OptionSimple("link,name,type"))
|
||||
}},
|
||||
}, mdb.HashAction(mdb.SHORT, mdb.LINK, mdb.FIELD, "time,hash,type,name,link")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if mdb.HashSelect(m, arg...); len(arg) == 0 || arg[0] == "" {
|
||||
m.Action(mdb.CREATE, mdb.PRUNES)
|
||||
|
@ -29,6 +29,19 @@ func _defs_list(m *ice.Message) string {
|
||||
}
|
||||
return m.OptionDefault(mdb.LIST, kit.Join(list, ice.SP))
|
||||
}
|
||||
|
||||
func _autogen_source(m *ice.Message, main, file string) {
|
||||
main = strings.ReplaceAll(main, ice.PT+GO, ice.PT+SHY)
|
||||
m.Cmd(nfs.DEFS, main, `title "{{.Option "name"}}"
|
||||
`)
|
||||
m.Cmd(nfs.PUSH, main, ice.NL, "source "+strings.TrimPrefix(file, ice.SRC+ice.PS))
|
||||
}
|
||||
func _autogen_script(m *ice.Message, dir string) {
|
||||
m.Cmd(nfs.DEFS, dir, `chapter "{{.Option "name"}}"
|
||||
|
||||
field {{.Option "key"}}
|
||||
`)
|
||||
}
|
||||
func _autogen_module(m *ice.Message, dir string) {
|
||||
m.Cmd(nfs.DEFS, dir, `package {{.Option "zone"}}
|
||||
|
||||
@ -75,55 +88,6 @@ func main() { print(ice.Run()) }
|
||||
})
|
||||
m.Cmd(nfs.SAVE, main, kit.Join(list, ice.NL))
|
||||
}
|
||||
func _autogen_script(m *ice.Message, dir string) {
|
||||
m.Cmd(nfs.DEFS, dir, `chapter "{{.Option "name"}}"
|
||||
|
||||
field {{.Option "key"}}
|
||||
`)
|
||||
}
|
||||
func _autogen_source(m *ice.Message, main, file string) {
|
||||
main = strings.ReplaceAll(main, ice.PT+GO, ice.PT+SHY)
|
||||
m.Cmd(nfs.DEFS, main, `title "{{.Option "name"}}"
|
||||
`)
|
||||
m.Cmd(nfs.PUSH, main, ice.NL, "source "+strings.TrimPrefix(file, ice.SRC+ice.PS))
|
||||
}
|
||||
func _autogen_mod(m *ice.Message, file string) (mod string) {
|
||||
host := web.OptionUserWeb(m).Hostname()
|
||||
if host == "" {
|
||||
host = path.Base(kit.Path(""))
|
||||
} else {
|
||||
host = path.Join(host, "x", path.Base(kit.Path("")))
|
||||
}
|
||||
|
||||
m.Cmd(nfs.DEFS, file, kit.Format(`module %s
|
||||
|
||||
go 1.11
|
||||
`, host))
|
||||
|
||||
m.Cmd(nfs.CAT, file, func(line string) {
|
||||
if strings.HasPrefix(line, "module") {
|
||||
mod = kit.Split(line, ice.SP)[1]
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
func _autogen_git(m *ice.Message, arg ...string) ice.Map {
|
||||
return kit.Dict("Path", kit.Path(""), "Time", m.Time(), arg,
|
||||
"Hash", strings.TrimSpace(m.Cmdx(cli.SYSTEM, GIT, "log", "-n1", `--pretty=%H`)),
|
||||
"Remote", strings.TrimSpace(m.Cmdx(cli.SYSTEM, GIT, "config", "remote.origin.url")),
|
||||
"Branch", strings.TrimSpace(m.Cmdx(cli.SYSTEM, GIT, "rev-parse", "--abbrev-ref", "HEAD")),
|
||||
"Version", strings.TrimSpace(m.Cmdx(cli.SYSTEM, GIT, "describe", "--tags")),
|
||||
"Domain", m.Option(ice.MSG_USERWEB),
|
||||
)
|
||||
}
|
||||
func _autogen_gits(m *ice.Message, arg ...string) string {
|
||||
res := []string{}
|
||||
kit.Fetch(_autogen_git(m, arg...), func(k string, v ice.Any) {
|
||||
res = append(res, kit.Format(` %s: "%s",`, k, v))
|
||||
})
|
||||
return kit.Join(res, ice.NL)
|
||||
}
|
||||
func _autogen_version(m *ice.Message) {
|
||||
if mod := _autogen_mod(m, ice.GO_MOD); !nfs.ExistsFile(m, ".git") {
|
||||
m.Cmdy(cli.SYSTEM, GIT, ice.INIT)
|
||||
@ -159,6 +123,42 @@ func init() {
|
||||
m.Cmdy(nfs.DIR, ice.SRC_VERSION_GO)
|
||||
m.Cmdy(nfs.DIR, ice.SRC_BINPACK_GO)
|
||||
}
|
||||
func _autogen_gits(m *ice.Message, arg ...string) string {
|
||||
res := []string{}
|
||||
kit.Fetch(_autogen_git(m, arg...), func(k string, v ice.Any) {
|
||||
res = append(res, kit.Format(` %s: "%s",`, k, v))
|
||||
})
|
||||
return kit.Join(res, ice.NL)
|
||||
}
|
||||
func _autogen_git(m *ice.Message, arg ...string) ice.Map {
|
||||
return kit.Dict("Path", kit.Path(""), "Time", m.Time(), arg,
|
||||
"Hash", strings.TrimSpace(m.Cmdx(cli.SYSTEM, GIT, "log", "-n1", `--pretty=%H`)),
|
||||
"Remote", strings.TrimSpace(m.Cmdx(cli.SYSTEM, GIT, "config", "remote.origin.url")),
|
||||
"Branch", strings.TrimSpace(m.Cmdx(cli.SYSTEM, GIT, "rev-parse", "--abbrev-ref", "HEAD")),
|
||||
"Version", strings.TrimSpace(m.Cmdx(cli.SYSTEM, GIT, "describe", "--tags")),
|
||||
"Domain", m.Option(ice.MSG_USERWEB),
|
||||
)
|
||||
}
|
||||
func _autogen_mod(m *ice.Message, file string) (mod string) {
|
||||
host := web.OptionUserWeb(m).Hostname()
|
||||
if host == "" {
|
||||
host = path.Base(kit.Path(""))
|
||||
} else {
|
||||
host = path.Join(host, "x", path.Base(kit.Path("")))
|
||||
}
|
||||
|
||||
m.Cmd(nfs.DEFS, file, kit.Format(`module %s
|
||||
|
||||
go 1.11
|
||||
`, host))
|
||||
|
||||
m.Cmd(nfs.CAT, file, func(line string) {
|
||||
if strings.HasPrefix(line, "module") {
|
||||
mod = kit.Split(line, ice.SP)[1]
|
||||
}
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
const AUTOGEN = "autogen"
|
||||
|
||||
@ -178,18 +178,18 @@ func init() {
|
||||
m.Option(mdb.TEXT, kit.Format("`name:\"%s\" help:\"%s\"`", _defs_list(m), m.Option(mdb.HELP)))
|
||||
|
||||
nfs.OptionFiles(m, nfs.DiskFile)
|
||||
if p := path.Join(m.Option(nfs.PATH), m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), SHY)); !nfs.ExistsFile(m, p) {
|
||||
_autogen_source(m, path.Join(m.Option(nfs.PATH), m.Option(cli.MAIN)), p)
|
||||
_autogen_script(m, p)
|
||||
}
|
||||
if p := path.Join(m.Option(nfs.PATH), m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), GO)); !nfs.ExistsFile(m, p) {
|
||||
_autogen_module(m, p)
|
||||
_autogen_import(m, path.Join(m.Option(nfs.PATH), m.Option(cli.MAIN)), m.Option(mdb.ZONE), _autogen_mod(m, ice.GO_MOD))
|
||||
}
|
||||
if p := path.Join(m.Option(nfs.PATH), m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), SHY)); !nfs.ExistsFile(m, p) {
|
||||
_autogen_script(m, p)
|
||||
_autogen_source(m, path.Join(m.Option(nfs.PATH), m.Option(cli.MAIN)), p)
|
||||
}
|
||||
m.Option(nfs.FILE, path.Join(m.Option(mdb.ZONE), kit.Keys(m.Option(mdb.NAME), GO)))
|
||||
_autogen_version(m.Spawn())
|
||||
}},
|
||||
ssh.SCRIPT: {Name: "script", Help: "脚本:生成 etc/miss.sh", Hand: func(m *ice.Message, arg ...string) {
|
||||
ssh.SCRIPT: {Name: "script", Help: "脚本", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(nfs.DEFS, ice.ETC_MISS_SH, _miss_script)
|
||||
defer m.Cmdy(nfs.CAT, ice.ETC_MISS_SH)
|
||||
|
||||
@ -201,7 +201,7 @@ func init() {
|
||||
_autogen_version(m)
|
||||
if m.Cmd(BINPACK, mdb.CREATE); nfs.ExistsFile(m, ice.USR_RELEASE) && m.Option(ice.MSG_USERPOD) == "" {
|
||||
m.Cmd(nfs.COPY, path.Join(ice.USR_RELEASE, "conf.go"), path.Join(ice.USR_ICEBERGS, "conf.go"))
|
||||
m.Cmd(cli.SYSTEM, "sh", "-c", `cat src/binpack.go|sed 's/package main/package ice/g' > usr/release/binpack.go`)
|
||||
cli.SystemCmds(m, `cat src/binpack.go|sed 's/package main/package ice/g' > usr/release/binpack.go`)
|
||||
m.Cmdy(nfs.DIR, "usr/release/binpack.go")
|
||||
m.Cmdy(nfs.DIR, "usr/release/conf.go")
|
||||
}
|
||||
|
@ -42,8 +42,7 @@ func _bench_http(m *ice.Message, target string, arg ...string) {
|
||||
n, _ := io.Copy(ioutil.Discard, res.Body)
|
||||
atomic.AddInt64(&ndata, n)
|
||||
}); m.Assert(e) {
|
||||
m.Echo("ndata: %s\n", kit.FmtSize(ndata))
|
||||
m.Echo(s.Show())
|
||||
m.Echo("ndata: %s\n", kit.FmtSize(ndata)).Echo(s.Show())
|
||||
m.ProcessInner()
|
||||
}
|
||||
}
|
||||
|
@ -16,21 +16,15 @@ import (
|
||||
)
|
||||
|
||||
func _binpack_file(m *ice.Message, w io.Writer, arg ...string) { // file name
|
||||
if f, e := nfs.OpenFile(m, arg[0]); e == nil {
|
||||
if f, e := nfs.OpenFile(m, arg[0]); !m.Warn(e, ice.ErrNotFound, arg[0]) {
|
||||
defer f.Close()
|
||||
if b, _ := ioutil.ReadAll(f); len(b) > 0 {
|
||||
fmt.Fprintf(w, " \"%s\": \"%s\",\n", kit.Select(arg[0], arg, 1), base64.StdEncoding.EncodeToString(b))
|
||||
return
|
||||
}
|
||||
}
|
||||
fmt.Fprintf(w, " // \"%s\": \"%s\",\n", kit.Select(arg[0], arg, 1), "")
|
||||
}
|
||||
func _binpack_dir(m *ice.Message, w io.Writer, dir string) {
|
||||
m.Option(nfs.DIR_ROOT, dir)
|
||||
m.Option(nfs.DIR_DEEP, true)
|
||||
m.Option(nfs.DIR_TYPE, nfs.CAT)
|
||||
|
||||
m.Cmd(nfs.DIR, nfs.PWD).Sort(nfs.PATH).Tables(func(value ice.Maps) {
|
||||
nfs.DirDeepAll(m, dir, nfs.PWD, func(value ice.Maps) {
|
||||
switch path.Base(value[nfs.PATH]) {
|
||||
case ice.GO_MOD, ice.GO_SUM, "binpack.go", "version.go":
|
||||
return
|
||||
@ -45,23 +39,16 @@ func _binpack_dir(m *ice.Message, w io.Writer, dir string) {
|
||||
}
|
||||
|
||||
func _binpack_can(m *ice.Message, w io.Writer, dir string) {
|
||||
m.Option(nfs.DIR_ROOT, dir)
|
||||
m.Option(nfs.DIR_DEEP, true)
|
||||
m.Option(nfs.DIR_TYPE, nfs.CAT)
|
||||
|
||||
for _, k := range []string{ice.FAVICON, ice.PROTO_JS, ice.FRAME_JS} {
|
||||
for _, k := range []string{ice.FAVICON_ICO, ice.PROTO_JS, ice.FRAME_JS} {
|
||||
_binpack_file(m, w, path.Join(dir, k), path.Join(ice.USR_VOLCANOS, k))
|
||||
}
|
||||
for _, k := range []string{LIB, PAGE, PANEL, PLUGIN, "publish/client/nodejs/"} {
|
||||
m.Cmd(nfs.DIR, k).Sort(nfs.PATH).Tables(func(value ice.Maps) {
|
||||
nfs.DirDeepAll(m, dir, k, func(value ice.Maps) {
|
||||
_binpack_file(m, w, path.Join(dir, value[nfs.PATH]), path.Join(ice.USR_VOLCANOS, value[nfs.PATH]))
|
||||
})
|
||||
}
|
||||
fmt.Fprintln(w)
|
||||
}
|
||||
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) {
|
||||
@ -93,11 +80,13 @@ func init() {
|
||||
fmt.Fprintln(w, ` pack := ice.Maps{`)
|
||||
defer fmt.Fprintln(w, ` }`)
|
||||
|
||||
if nfs.ExistsFile(m, ice.USR_VOLCANOS) && nfs.ExistsFile(m, ice.USR_INTSHELL) && m.Option(ice.MSG_USERPOD) == "" {
|
||||
if nfs.ExistsFile(m, ice.USR_VOLCANOS) && m.Option(ice.MSG_USERPOD) == "" {
|
||||
_binpack_can(m, w, ice.USR_VOLCANOS)
|
||||
}
|
||||
if nfs.ExistsFile(m, ice.USR_INTSHELL) && m.Option(ice.MSG_USERPOD) == "" {
|
||||
_binpack_dir(m, w, ice.USR_INTSHELL)
|
||||
}
|
||||
_binpack_ctx(m, w)
|
||||
_binpack_dir(m, w, ice.SRC)
|
||||
|
||||
_binpack_file(m, w, ice.ETC_MISS_SH)
|
||||
_binpack_file(m, w, ice.ETC_INIT_SHY)
|
||||
@ -154,6 +143,6 @@ func init() {
|
||||
mdb.INSERT: {Name: "insert path", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.HashCreate(m, nfs.PATH, m.Option(nfs.PATH))
|
||||
}},
|
||||
}, mdb.HashAction(mdb.SHORT, nfs.PATH))},
|
||||
}, mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path"))},
|
||||
})
|
||||
}
|
||||
|
@ -11,12 +11,10 @@ import (
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func _c_show(m *ice.Message, arg ...string) {
|
||||
TagsList(m, "ctags", "--excmd=number", "--sort=no", "-f", "-", path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE)))
|
||||
}
|
||||
func _c_show(m *ice.Message, arg ...string) { TagsList(m) }
|
||||
func _c_exec(m *ice.Message, arg ...string) {
|
||||
name := strings.TrimSuffix(arg[1], path.Ext(arg[1])) + ".bin"
|
||||
if msg := m.Cmd(cli.SYSTEM, "gcc", arg[1], "-o", name, kit.Dict(cli.CMD_DIR, arg[2])); !cli.IsSuccess(msg) {
|
||||
if msg := m.Cmd(cli.SYSTEM, "gcc", "-o", name, arg[1], kit.Dict(cli.CMD_DIR, arg[2])); !cli.IsSuccess(msg) {
|
||||
_vimer_make(m, arg[2], msg)
|
||||
return
|
||||
}
|
||||
@ -47,9 +45,8 @@ func init() {
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _c_exec(m, arg...) }},
|
||||
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, MAN, "ctags", "-a", "-R", nfs.PWD) }},
|
||||
}, PlugAction(), LangAction())},
|
||||
H: {Name: "c path auto", Help: "系统", Actions: ice.MergeActions(ice.Actions{
|
||||
H: {Name: "h path auto", Help: "系统", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _c_show(m, arg...) }},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _c_exec(m, arg...) }},
|
||||
NAVIGATE: {Hand: func(m *ice.Message, arg ...string) { _c_tags(m, MAN, "ctags", "-a", "-R", nfs.PWD) }},
|
||||
}, PlugAction(), LangAction())},
|
||||
MAN: {Name: MAN, Help: "手册", Actions: ice.MergeActions(ice.Actions{
|
||||
@ -59,7 +56,7 @@ func init() {
|
||||
}
|
||||
key := kit.TrimExt(arg[1], arg[0])
|
||||
m.Option(cli.CMD_ENV, "COLUMNS", kit.Int(kit.Select("1920", m.Option("width")))/12)
|
||||
m.Cmdy(cli.SYSTEM, "sh", "-c", kit.Format("man %s %s|col -b", "", key))
|
||||
m.Echo(cli.SystemCmds(m, "man %s %s|col -b", "", key))
|
||||
}},
|
||||
}, PlugAction())},
|
||||
})
|
||||
|
@ -21,7 +21,7 @@ var Index = &ice.Context{Name: CODE, Help: "编程中心", Commands: ice.Command
|
||||
|
||||
func init() {
|
||||
web.Index.Register(Index, &web.Frame{},
|
||||
INSTALL, WEBPACK, BINPACK, AUTOGEN, COMPILE, PUBLISH, UPGRADE,
|
||||
INSTALL, UPGRADE, WEBPACK, BINPACK, AUTOGEN, COMPILE, PUBLISH,
|
||||
FAVOR, XTERM, INNER, VIMER, PPROF, BENCH,
|
||||
C, SH, SHY, GO, JS,
|
||||
)
|
||||
|
@ -2,16 +2,16 @@ chapter "源码"
|
||||
code.go
|
||||
code.shy
|
||||
|
||||
section "开发流程"
|
||||
section "流程"
|
||||
install.go
|
||||
upgrade.go
|
||||
webpack.go
|
||||
binpack.go
|
||||
autogen.go
|
||||
compile.go
|
||||
publish.go
|
||||
upgrade.go
|
||||
|
||||
section "编程工具"
|
||||
section "工具"
|
||||
favor.go
|
||||
xterm.go
|
||||
xterm.shy
|
||||
@ -22,12 +22,11 @@ bench.go
|
||||
oauth.go
|
||||
case.go
|
||||
|
||||
section "编程语言"
|
||||
section "语言"
|
||||
c.go
|
||||
sh.go
|
||||
py.go
|
||||
shy.go
|
||||
zml.go
|
||||
py.go
|
||||
go.go
|
||||
js.go
|
||||
|
||||
|
@ -13,13 +13,12 @@ import (
|
||||
)
|
||||
|
||||
func _compile_target(m *ice.Message, arg ...string) (string, string, string, string) {
|
||||
arch, goos := runtime.GOARCH, runtime.GOOS
|
||||
main, file := ice.SRC_MAIN_GO, ""
|
||||
main, file, goos, arch := ice.SRC_MAIN_GO, "", runtime.GOOS, runtime.GOARCH
|
||||
for _, k := range arg {
|
||||
switch k {
|
||||
case cli.AMD64, cli.X86, cli.ARM, cli.ARM64, cli.MIPSLE:
|
||||
case cli.AMD64, cli.X86, cli.MIPSLE, cli.ARM, cli.ARM64:
|
||||
arch = k
|
||||
case cli.WINDOWS, cli.DARWIN, cli.LINUX:
|
||||
case cli.LINUX, cli.DARWIN, cli.WINDOWS:
|
||||
goos = k
|
||||
default:
|
||||
if kit.Ext(k) == GO {
|
||||
@ -30,7 +29,7 @@ func _compile_target(m *ice.Message, arg ...string) (string, string, string, str
|
||||
}
|
||||
}
|
||||
if file == "" {
|
||||
file = path.Join(m.Config(nfs.PATH), kit.Keys(kit.Select(ice.ICE, kit.TrimExt(main), main != ice.SRC_MAIN_GO), goos, arch))
|
||||
file = path.Join(ice.USR_PUBLISH, kit.Keys(kit.Select(ice.ICE, kit.TrimExt(main), main != ice.SRC_MAIN_GO), goos, arch))
|
||||
}
|
||||
return main, file, goos, arch
|
||||
}
|
||||
@ -42,11 +41,9 @@ const COMPILE = "compile"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Configs: ice.Configs{
|
||||
COMPILE: {Value: kit.Data(nfs.PATH, ice.USR_PUBLISH,
|
||||
cli.ENV, kit.Dict("GOPRIVATE", "shylinux.com,github.com", "GOPROXY", "https://goproxy.cn,direct", "CGO_ENABLED", "0"),
|
||||
)},
|
||||
COMPILE: {Value: kit.Data(cli.ENV, kit.Dict("GOPRIVATE", "shylinux.com,github.com", "GOPROXY", "https://goproxy.cn,direct", "CGO_ENABLED", "0"))},
|
||||
}, Commands: ice.Commands{
|
||||
COMPILE: {Name: "compile arch=amd64,386,arm,arm64,mipsle os=linux,darwin,windows src=src/main.go@key run binpack relay", Help: "编译", Actions: ice.Actions{
|
||||
COMPILE: {Name: "compile arch=amd64,386,mipsle,arm,arm64 os=linux,darwin,windows src=src/main.go@key run binpack relay", Help: "编译", Actions: ice.Actions{
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(nfs.DIR, ice.SRC, nfs.DIR_CLI_FIELDS, kit.Dict(nfs.DIR_REG, `.*\.go$`)).Sort(nfs.PATH)
|
||||
}},
|
||||
@ -57,7 +54,6 @@ func init() {
|
||||
m.Cmdy(COMPILE, ice.SRC_RELAY_GO, path.Join(ice.USR_PUBLISH, RELAY))
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, arg ...string) {
|
||||
// 下载依赖
|
||||
_autogen_version(m.Spawn())
|
||||
|
||||
// 执行编译
|
||||
|
@ -14,12 +14,12 @@ func init() {
|
||||
Index.MergeCommands(ice.Commands{
|
||||
FAVOR: {Name: "favor zone id auto insert page", Help: "收藏夹", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.INSERT: {Name: "insert zone=数据结构 type=go name=hi text=hello path file line", Help: "添加"},
|
||||
INNER: {Name: "inner", Help: "源码", Hand: func(m *ice.Message, arg ...string) {
|
||||
ctx.Process(m, m.ActionKey(), m.OptionSplit(nfs.PATH, nfs.FILE, nfs.LINE), arg...)
|
||||
}},
|
||||
XTERM: {Name: "xterm", Help: "终端", Hand: func(m *ice.Message, arg ...string) {
|
||||
ctx.Process(m, m.ActionKey(), m.OptionSimple(mdb.TYPE, mdb.NAME, mdb.TEXT), arg...)
|
||||
}},
|
||||
INNER: {Name: "inner", Help: "源码", Hand: func(m *ice.Message, arg ...string) {
|
||||
ctx.Process(m, m.ActionKey(), m.OptionSplit(nfs.PATH, nfs.FILE, nfs.LINE), arg...)
|
||||
}},
|
||||
}, mdb.ZoneAction(mdb.SHORT, mdb.ZONE, mdb.FIELD, "time,id,type,name,text,path,file,line")), Hand: func(m *ice.Message, arg ...string) {
|
||||
if mdb.ZoneSelectPage(m, arg...); len(arg) > 0 && arg[0] != "" {
|
||||
m.Tables(func(value ice.Maps) {
|
||||
|
@ -12,6 +12,19 @@ import (
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
func _go_trans(m *ice.Message, key string) string {
|
||||
switch key {
|
||||
case "m", "msg":
|
||||
key = "icebergs.Message"
|
||||
case "kit":
|
||||
key = "shylinux.com/x/toolkits"
|
||||
case "ice":
|
||||
key = "shylinux.com/x/ice"
|
||||
case "mdb", "cli", "nfs":
|
||||
key = "shylinux.com/x/icebergs/base/" + key
|
||||
}
|
||||
return key
|
||||
}
|
||||
func _go_complete(m *ice.Message, arg ...string) {
|
||||
if m.Option(mdb.TEXT) == "" {
|
||||
m.Push(mdb.TEXT, "package", "import", "const", "type", "func", "var")
|
||||
@ -20,16 +33,7 @@ func _go_complete(m *ice.Message, arg ...string) {
|
||||
|
||||
if strings.HasSuffix(m.Option(mdb.TEXT), ice.PT) {
|
||||
key := kit.Slice(kit.Split(m.Option(mdb.TEXT), "\t ."), -1)[0]
|
||||
switch key {
|
||||
case "m", "msg":
|
||||
key = "icebergs.Message"
|
||||
case "kit":
|
||||
key = "shylinux.com/x/toolkits"
|
||||
case "ice":
|
||||
key = "shylinux.com/x/ice"
|
||||
case "mdb", "cli", "nfs":
|
||||
key = "shylinux.com/x/icebergs/base/" + key
|
||||
}
|
||||
key = _go_trans(m, key)
|
||||
|
||||
msg := m.Cmd(cli.SYSTEM, GO, "doc", key)
|
||||
for _, l := range strings.Split(kit.Select(msg.Result(), msg.Append(cli.CMD_OUT)), ice.NL) {
|
||||
@ -56,7 +60,7 @@ func _go_complete(m *ice.Message, arg ...string) {
|
||||
}
|
||||
}
|
||||
func _go_exec(m *ice.Message, arg ...string) {
|
||||
args := []string{"./bin/ice.bin"}
|
||||
args := []string{ice.ICE_BIN}
|
||||
if cmd := ctx.GetFileCmd(path.Join(arg[2], arg[1])); cmd != "" {
|
||||
args = append(args, cmd)
|
||||
}
|
||||
@ -88,6 +92,7 @@ func _mod_show(m *ice.Message, file string) {
|
||||
replace := ice.Maps{}
|
||||
m.Cmd(nfs.CAT, file, func(ls []string, line string) {
|
||||
switch {
|
||||
case strings.HasPrefix(line, "//"):
|
||||
case strings.HasPrefix(line, MODULE):
|
||||
require[ls[1]] = m.Cmdx(cli.SYSTEM, GIT, "describe", "--tags")
|
||||
replace[ls[1]] = nfs.PWD
|
||||
@ -154,10 +159,9 @@ func init() {
|
||||
}, PlugAction(), LangAction())},
|
||||
GODOC: {Name: "godoc", Help: "文档", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
arg[1] = strings.Replace(arg[1], "m.", "shylinux.com/x/ice.Message.", 1)
|
||||
arg[1] = strings.Replace(arg[1], "kit.", "shylinux.com/x/toolkits.", 1)
|
||||
m.Cmdy(cli.SYSTEM, GO, "doc", strings.TrimSuffix(arg[1], ".godoc"), kit.Dict(cli.CMD_DIR, arg[2]))
|
||||
if m.Append(cli.CMD_ERR) != "" {
|
||||
arg[1] = strings.Replace(arg[1], "m.", "shylinux.com/x/ice.Message.", 1)
|
||||
if m.Cmdy(cli.SYSTEM, GO, "doc", strings.TrimSuffix(arg[1], ".godoc"), kit.Dict(cli.CMD_DIR, arg[2])); m.Append(cli.CMD_ERR) != "" {
|
||||
m.Result(m.Append(cli.CMD_OUT))
|
||||
}
|
||||
}},
|
||||
|
@ -73,9 +73,9 @@ const (
|
||||
FUNCTION = "function"
|
||||
)
|
||||
const (
|
||||
SPLIT = lex.SPLIT
|
||||
SPACE = "space"
|
||||
OPERATE = "operate"
|
||||
SPLIT = lex.SPLIT
|
||||
PREFIX = lex.PREFIX
|
||||
SUFFIX = lex.SUFFIX
|
||||
)
|
||||
@ -173,17 +173,20 @@ func PlugAction() ice.Actions {
|
||||
}},
|
||||
}
|
||||
}
|
||||
func LoadPlug(m *ice.Message, language ...string) {
|
||||
for _, language := range language {
|
||||
m.Conf(nfs.CAT, kit.Keym(nfs.SOURCE, kit.Ext(language)), ice.TRUE)
|
||||
m.Confm(language, kit.Keym(PLUG, PREPARE), func(key string, value ice.Any) {
|
||||
func LoadPlug(m *ice.Message, lang ...string) {
|
||||
for _, lang := range lang {
|
||||
m.Conf(nfs.CAT, kit.Keym(nfs.SOURCE, kit.Ext(lang)), ice.TRUE)
|
||||
m.Confm(lang, kit.Keym(PLUG, PREPARE), func(key string, value ice.Any) {
|
||||
for _, v := range kit.Simple(value) {
|
||||
m.Conf(language, kit.Keym(PLUG, KEYWORD, v), key)
|
||||
m.Conf(lang, kit.Keym(PLUG, KEYWORD, v), key)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
func TagsList(m *ice.Message, cmds ...string) {
|
||||
if len(cmds) == 0 {
|
||||
cmds = []string{"ctags", "--excmd=number", "--sort=no", "-f", "-", path.Join(m.Option(nfs.PATH), m.Option(nfs.FILE))}
|
||||
}
|
||||
for _, l := range strings.Split(m.Cmdx(cli.SYSTEM, cmds), ice.NL) {
|
||||
if strings.HasPrefix(l, "!_") {
|
||||
continue
|
||||
|
@ -23,7 +23,7 @@ func _install_path(m *ice.Message, link string) string {
|
||||
return p
|
||||
}
|
||||
if p := path.Join(ice.USR_INSTALL, path.Base(link)); nfs.ExistsFile(m, p) {
|
||||
return path.Join(ice.USR_INSTALL, strings.Split(m.Cmdx(cli.SYSTEM, "sh", "-c", kit.Format("tar tf %s| head -n1", p), ice.Option{cli.CMD_OUTPUT, ""}), ice.PS)[0])
|
||||
return path.Join(ice.USR_INSTALL, strings.Split(cli.SystemCmds(m, "tar tf %s| head -n1", p), ice.PS)[0])
|
||||
}
|
||||
m.Warn(true, ice.ErrNotFound, link)
|
||||
return ""
|
||||
@ -43,7 +43,7 @@ func _install_download(m *ice.Message) {
|
||||
begin, last := time.Now(), time.Now()
|
||||
mdb.HashCreate(m, mdb.NAME, name, nfs.PATH, file, mdb.LINK, link)
|
||||
web.GoToast(m, name, func(toast func(string, int, int)) {
|
||||
m.Cmd("web.spide", ice.DEV, web.SPIDE_SAVE, file, web.SPIDE_GET, link, func(count int, total int, step int) {
|
||||
web.SpideSave(m, file, link, func(count int, total int, step int) {
|
||||
mdb.HashSelectUpdate(m, name, func(value ice.Map) { value[mdb.COUNT], value[mdb.TOTAL], value[mdb.VALUE] = count, total, step })
|
||||
|
||||
if now := time.Now(); now.Sub(last) > 500*time.Millisecond {
|
||||
@ -57,8 +57,7 @@ func _install_download(m *ice.Message) {
|
||||
m.Cmd(nfs.TAR, mdb.EXPORT, name, kit.Dict(cli.CMD_DIR, path.Dir(file)))
|
||||
web.ToastSuccess(m)
|
||||
})
|
||||
m.Cmdy(nfs.DIR, file)
|
||||
m.SetResult()
|
||||
m.Cmdy(nfs.DIR, file).SetResult()
|
||||
}
|
||||
func _install_build(m *ice.Message, arg ...string) string {
|
||||
p := m.Option(cli.CMD_DIR, _install_path(m, ""))
|
||||
@ -72,14 +71,17 @@ func _install_build(m *ice.Message, arg ...string) string {
|
||||
switch cb := m.Optionv(PREPARE).(type) {
|
||||
case func(string):
|
||||
cb(p)
|
||||
default:
|
||||
case nil:
|
||||
if msg := m.Cmd(cli.SYSTEM, "./configure", "--prefix="+pp, arg[1:]); !cli.IsSuccess(msg) {
|
||||
return msg.Append(cli.CMD_ERR)
|
||||
}
|
||||
default:
|
||||
m.ErrorNotImplement(cb)
|
||||
return m.Result()
|
||||
}
|
||||
|
||||
// 编译
|
||||
if msg := m.Cmd(cli.SYSTEM, cli.MAKE, "-j8"); !cli.IsSuccess(msg) {
|
||||
if msg := m.Cmd(cli.SYSTEM, cli.MAKE, "-j"+m.Cmdx(cli.RUNTIME, cli.MAXPROCS)); !cli.IsSuccess(msg) {
|
||||
return msg.Append(cli.CMD_ERR) + msg.Append(cli.CMD_OUT)
|
||||
}
|
||||
|
||||
@ -92,7 +94,7 @@ func _install_build(m *ice.Message, arg ...string) string {
|
||||
func _install_order(m *ice.Message, arg ...string) {
|
||||
p := _install_path(m, "")
|
||||
if m.Option(nfs.PATH) == "" {
|
||||
for _, v := range []string{"_install/bin", "bin", ""} {
|
||||
for _, v := range []string{"_install/bin", "bin", "sbin", ""} {
|
||||
if nfs.ExistsFile(m, path.Join(p, v)) {
|
||||
m.Option(nfs.PATH, v)
|
||||
break
|
||||
@ -137,6 +139,7 @@ func _install_start(m *ice.Message, arg ...string) {
|
||||
case nil:
|
||||
default:
|
||||
m.ErrorNotImplement(cb)
|
||||
return
|
||||
}
|
||||
|
||||
bin := kit.Split(path.Base(arg[0]), "-.")[0]
|
||||
|
@ -36,21 +36,13 @@ func _js_main_script(m *ice.Message, arg ...string) (res []string) {
|
||||
}
|
||||
|
||||
func _js_show(m *ice.Message, arg ...string) {
|
||||
key := ctx.GetFileCmd(kit.Replace(path.Join(arg[2], arg[1]), ".js", ".go"))
|
||||
if key == "" {
|
||||
for p, k := range ice.Info.File {
|
||||
if strings.HasPrefix(p, path.Dir(path.Join(arg[2], arg[1]))) {
|
||||
key = k
|
||||
}
|
||||
}
|
||||
}
|
||||
m.Display(path.Join("/require", path.Join(arg[2], arg[1])))
|
||||
key := ctx.GetFileCmd(kit.Replace(path.Join(arg[2], arg[1]), ".js", ".go"))
|
||||
ctx.ProcessCommand(m, kit.Select("can.code.inner._plugin", key), kit.Simple())
|
||||
}
|
||||
func _js_exec(m *ice.Message, arg ...string) {
|
||||
args := kit.Simple("node", "-e", kit.Join(_js_main_script(m, arg...), ice.NL))
|
||||
m.Cmdy(cli.SYSTEM, args)
|
||||
m.StatusTime(ctx.ARGS, kit.Join([]string{"./bin/ice.bin", "web.code.js.js", "exec", path.Join(arg[2], arg[1])}, ice.SP))
|
||||
m.Cmdy(cli.SYSTEM, args).StatusTime(ctx.ARGS, kit.Join(append([]string{ice.ICE_BIN, m.PrefixKey(), m.ActionKey()}, arg...), ice.SP))
|
||||
}
|
||||
|
||||
const JS = "js"
|
||||
@ -64,24 +56,17 @@ func init() {
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) { _js_show(m, arg...) }},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _js_exec(m, arg...) }},
|
||||
|
||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(`
|
||||
Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg) {
|
||||
msg.Echo("hello world")
|
||||
msg.Dump(can)
|
||||
}})
|
||||
`)
|
||||
}},
|
||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(_js_template) }},
|
||||
COMPLETE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 0 && arg[0] == mdb.FOREACH {
|
||||
if len(arg) > 0 && arg[0] == mdb.FOREACH { // 文件
|
||||
switch m.Option(ctx.ACTION) {
|
||||
case nfs.SCRIPT:
|
||||
m.Push(nfs.PATH, strings.ReplaceAll(arg[1], ice.PT+kit.Ext(arg[1]), ice.PT+JS))
|
||||
m.Cmdy(nfs.DIR, nfs.PWD, kit.Dict(nfs.DIR_ROOT, "src/", nfs.DIR_REG, `.*\.(sh|shy|py|js)$`, nfs.DIR_DEEP, ice.TRUE), nfs.PATH)
|
||||
m.Option(nfs.DIR_REG, `.*\.(sh|py|shy|js)$`)
|
||||
nfs.DirDeepAll(m, ice.SRC, nfs.PWD, nil).Cut(nfs.PATH)
|
||||
}
|
||||
return
|
||||
}
|
||||
if strings.HasSuffix(m.Option(mdb.TEXT), ice.PT) {
|
||||
|
||||
} else if strings.HasSuffix(m.Option(mdb.TEXT), ice.PT) { // 方法
|
||||
key := kit.Slice(kit.Split(m.Option(mdb.TEXT), "\t ."), -1)[0]
|
||||
switch key {
|
||||
case "msg":
|
||||
@ -91,10 +76,17 @@ Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg) {
|
||||
default:
|
||||
m.Cmdy("web.code.vim.tags", strings.TrimPrefix(m.Option(mdb.TYPE), "can.")).Cut("name,text")
|
||||
}
|
||||
} else {
|
||||
|
||||
} else { // 类型
|
||||
m.Cmdy("web.code.vim.tags").Cut(mdb.ZONE)
|
||||
}
|
||||
}},
|
||||
}, PlugAction(), LangAction())},
|
||||
})
|
||||
}
|
||||
|
||||
var _js_template = `
|
||||
Volcanos(chat.ONIMPORT, {help: "导入数据", _init: function(can, msg) {
|
||||
msg.Echo("hello world").Dump(can)
|
||||
}})
|
||||
`
|
||||
|
@ -10,7 +10,6 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/aaa"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/gdb"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
"shylinux.com/x/icebergs/base/tcp"
|
||||
@ -35,15 +34,13 @@ func _publish_file(m *ice.Message, file string, arg ...string) string {
|
||||
return target
|
||||
}
|
||||
func _publish_list(m *ice.Message, arg ...string) {
|
||||
m.Option(nfs.DIR_DEEP, true)
|
||||
m.Option(nfs.DIR_ROOT, ice.USR_PUBLISH)
|
||||
m.Option(nfs.DIR_REG, kit.Select("", arg, 0))
|
||||
m.Cmdy(nfs.DIR, nfs.PWD, kit.Select(nfs.DIR_WEB_FIELDS, arg, 1))
|
||||
nfs.DirDeepAll(m, ice.USR_PUBLISH, nfs.PWD, nil, kit.Select(nfs.DIR_WEB_FIELDS, arg, 1))
|
||||
}
|
||||
func _publish_bin_list(m *ice.Message, dir string) {
|
||||
p := m.Option(cli.CMD_DIR, dir)
|
||||
for _, ls := range strings.Split(strings.TrimSpace(m.Cmdx(cli.SYSTEM, "bash", "-c", "ls |xargs file |grep executable")), ice.NL) {
|
||||
if file := strings.TrimSpace(strings.Split(ls, ":")[0]); file != "" {
|
||||
for _, ls := range strings.Split(cli.SystemCmds(m, "ls |xargs file |grep executable"), ice.NL) {
|
||||
if file := strings.TrimSpace(strings.Split(ls, ice.DF)[0]); file != "" {
|
||||
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()))
|
||||
@ -55,6 +52,37 @@ func _publish_bin_list(m *ice.Message, dir string) {
|
||||
}
|
||||
m.SortTimeR(mdb.TIME)
|
||||
}
|
||||
func _publish_contexts(m *ice.Message, arg ...string) {
|
||||
u := web.OptionUserWeb(m)
|
||||
host := strings.Split(u.Host, ice.DF)[0]
|
||||
if host == tcp.LOCALHOST {
|
||||
host = m.Cmd(tcp.HOST).Append(aaa.IP)
|
||||
}
|
||||
m.Option(cli.CTX_ENV, kit.Select("", ice.SP+kit.JoinKV(ice.EQ, ice.SP, cli.CTX_POD, m.Option(ice.MSG_USERPOD)), m.Option(ice.MSG_USERPOD) != ""))
|
||||
m.Option("httphost", fmt.Sprintf("%s://%s:%s", u.Scheme, host, kit.Select(kit.Select("443", "80", u.Scheme == ice.HTTP), strings.Split(u.Host, ice.DF), 1)))
|
||||
|
||||
if len(arg) == 0 {
|
||||
arg = append(arg, ice.MISC)
|
||||
}
|
||||
for _, k := range arg {
|
||||
switch k {
|
||||
case INSTALL:
|
||||
m.Echo(kit.Renders(`export ctx_dev={{.Option "httphost"}}{{.Option "ctx_env"}}; ctx_temp=$(mktemp); wget -O $ctx_temp -q $ctx_dev; source $ctx_temp app username {{.Option "user.name"}}`, m))
|
||||
return
|
||||
|
||||
case ice.MISC:
|
||||
_publish_file(m, ice.ICE_BIN)
|
||||
|
||||
case ice.BASE:
|
||||
m.Option("remote", kit.Select(ice.Info.Make.Remote, cli.SystemExec(m, "git", "config", "remote.origin.url")))
|
||||
m.Option("pathname", strings.TrimSuffix(path.Base(m.Option("remote")), ".git"))
|
||||
}
|
||||
|
||||
if buf, err := kit.Render(m.Config(kit.Keys(ice.CONTEXTS, k)), m); m.Assert(err) {
|
||||
m.EchoScript(strings.TrimSpace(string(buf)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const (
|
||||
GIT = "git"
|
||||
@ -62,18 +90,14 @@ const (
|
||||
const PUBLISH = "publish"
|
||||
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Configs: ice.Configs{
|
||||
PUBLISH: {Name: PUBLISH, Help: "发布", Value: kit.Data(ice.CONTEXTS, _contexts)},
|
||||
}, Commands: ice.Commands{
|
||||
Index.Merge(&ice.Context{Commands: ice.Commands{
|
||||
PUBLISH: {Name: "publish path auto create volcanos icebergs intshell", Help: "发布", Actions: ice.Actions{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, ice.USR_PUBLISH)
|
||||
m.Cmd(aaa.ROLE, aaa.WHITE, aaa.VOID, m.PrefixKey())
|
||||
gdb.Watch(m, web.SERVE_START, m.PrefixKey())
|
||||
m.Config(ice.CONTEXTS, _contexts)
|
||||
}},
|
||||
web.SERVE_START: {Name: "serve.start", Help: "服务启动", Hand: func(m *ice.Message, arg ...string) {
|
||||
// _publish_file(m, ice.ICE_BIN)
|
||||
_publish_file(m, ice.ICE_BIN)
|
||||
}},
|
||||
ice.VOLCANOS: {Name: "volcanos", Help: "火山架", Hand: func(m *ice.Message, arg ...string) {
|
||||
defer func() { m.EchoQRCode(m.Option(ice.MSG_USERWEB)) }()
|
||||
@ -89,41 +113,7 @@ func init() {
|
||||
_publish_list(m, `.*\.(sh|vim|conf)$`)
|
||||
}},
|
||||
ice.CONTEXTS: {Name: "contexts", Help: "环境", Hand: func(m *ice.Message, arg ...string) {
|
||||
u := web.OptionUserWeb(m)
|
||||
host := strings.Split(u.Host, ice.DF)[0]
|
||||
if host == tcp.LOCALHOST {
|
||||
host = m.Cmd(tcp.HOST).Append(aaa.IP)
|
||||
}
|
||||
m.Option(cli.CTX_ENV, kit.Select("", " "+kit.JoinKV("=", " ", cli.CTX_POD, m.Option(ice.MSG_USERPOD)), m.Option(ice.MSG_USERPOD) != ""))
|
||||
m.Option("httphost", fmt.Sprintf("%s://%s:%s", u.Scheme, host, kit.Select(kit.Select("443", "80", u.Scheme == ice.HTTP), strings.Split(u.Host, ice.DF), 1)))
|
||||
|
||||
if len(arg) == 0 {
|
||||
arg = append(arg, ice.MISC)
|
||||
}
|
||||
for _, k := range arg {
|
||||
switch k {
|
||||
case INSTALL:
|
||||
m.Echo(kit.Renders(`export ctx_dev={{.Option "httphost"}}{{.Option "ctx_env"}}; ctx_temp=$(mktemp); wget -O $ctx_temp -q $ctx_dev; source $ctx_temp app username {{.Option "user.name"}}`, m))
|
||||
return
|
||||
case ice.MISC:
|
||||
if bin := path.Join(ice.USR_PUBLISH, kit.Keys(ice.ICE, runtime.GOOS, runtime.GOARCH)); !nfs.ExistsFile(m, bin) {
|
||||
m.Cmd(nfs.LINK, bin, m.Cmdx(cli.RUNTIME, "boot.bin"))
|
||||
}
|
||||
|
||||
case ice.CORE, ice.BASE:
|
||||
if !nfs.ExistsFile(m, ".git") {
|
||||
repos := web.MergeURL2(m, "/x/"+kit.Select(ice.Info.PathName, m.Option(ice.MSG_USERPOD)))
|
||||
m.Cmd(cli.SYSTEM, "git", "init")
|
||||
m.Cmd(cli.SYSTEM, "git", "remote", "add", "origin", repos)
|
||||
m.Cmd("web.code.git.repos", mdb.CREATE, repos, "master", "", nfs.PWD)
|
||||
}
|
||||
m.Option("remote", kit.Select(ice.Info.Make.Remote, strings.TrimSpace(m.Cmdx(cli.SYSTEM, "git", "config", "remote.origin.url"))))
|
||||
m.Option("pathname", strings.TrimSuffix(path.Base(m.Option("remote")), ".git"))
|
||||
}
|
||||
if buf, err := kit.Render(m.Config(kit.Keys(ice.CONTEXTS, k)), m); m.Assert(err) {
|
||||
m.EchoScript(strings.TrimSpace(string(buf)))
|
||||
}
|
||||
}
|
||||
_publish_contexts(m, arg...)
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(nfs.DIR, kit.Select(nfs.PWD, arg, 1)).ProcessAgain()
|
||||
@ -134,35 +124,11 @@ func init() {
|
||||
nfs.TRASH: {Name: "trash", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmd(nfs.TRASH, path.Join(ice.USR_PUBLISH, m.Option(nfs.PATH)))
|
||||
}},
|
||||
mdb.EXPORT: {Name: "export", Help: "工具链", Hand: func(m *ice.Message, arg ...string) {
|
||||
var list = []string{ice.ETC_PATH}
|
||||
m.Cmd(nfs.CAT, ice.ETC_PATH, func(text string) {
|
||||
if strings.HasPrefix(text, ice.USR_PUBLISH) {
|
||||
return
|
||||
}
|
||||
if strings.HasPrefix(text, ice.BIN) {
|
||||
return
|
||||
}
|
||||
if strings.HasPrefix(text, ice.PS) {
|
||||
return
|
||||
}
|
||||
list = append(list, text)
|
||||
})
|
||||
|
||||
web.PushStream(m)
|
||||
defer m.ProcessHold()
|
||||
defer m.StatusTimeCount()
|
||||
defer web.ToastSuccess(m)
|
||||
m.Cmd(nfs.TAR, kit.Path(ice.USR_PUBLISH, "contexts.bin.tar.gz"), list)
|
||||
m.Cmd(nfs.TAR, kit.Path(ice.USR_PUBLISH, "contexts.src.tar.gz"), ice.MAKEFILE, ice.ETC_MISS_SH, ice.SRC_MAIN_GO, ice.GO_MOD, ice.GO_SUM)
|
||||
m.Cmd(nfs.TAR, kit.Path(ice.USR_PUBLISH, "contexts.home.tar.gz"), ".vim/plugged", kit.Dict(nfs.DIR_ROOT, kit.Env(cli.HOME)))
|
||||
m.Cmd("web.code.git.server", mdb.IMPORT)
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(nfs.DIR_ROOT, ice.USR_PUBLISH)
|
||||
m.Cmdy(nfs.DIR, kit.Select("", arg, 0), nfs.DIR_WEB_FIELDS)
|
||||
}},
|
||||
}})
|
||||
}, Configs: ice.Configs{PUBLISH: {Value: kit.Data(ice.CONTEXTS, _contexts)}}})
|
||||
}
|
||||
|
||||
var _contexts = kit.Dict(
|
||||
|
@ -30,22 +30,12 @@ func init() {
|
||||
Index.MergeCommands(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()
|
||||
cli.IsAlpine(m, "python", "python2")
|
||||
cli.IsAlpine(m, "python2")
|
||||
cli.IsAlpine(m, "python3")
|
||||
})
|
||||
}},
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
// _py_exec(m, arg...)
|
||||
}},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
_py_exec(m, arg...)
|
||||
}},
|
||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(`print "hello world"`)
|
||||
cli.IsAlpine(m, "python", "python2")
|
||||
cli.IsAlpine(m, "python2")
|
||||
cli.IsAlpine(m, "python3")
|
||||
}},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) { _py_exec(m, arg...) }},
|
||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) { m.Echo(`print "hello world"`) }},
|
||||
}, PlugAction(), LangAction())},
|
||||
})
|
||||
}
|
||||
|
@ -7,29 +7,31 @@ import (
|
||||
ice "shylinux.com/x/icebergs"
|
||||
"shylinux.com/x/icebergs/base/ctx"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/ssh"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
const SHY = "shy"
|
||||
|
||||
func init() {
|
||||
const WEB_WIKI_WORD = "web.wiki.word"
|
||||
Index.MergeCommands(ice.Commands{
|
||||
SHY: {Name: "shy path auto", Help: "脚本", Actions: ice.MergeActions(ice.Actions{
|
||||
mdb.RENDER: {Hand: func(m *ice.Message, arg ...string) {
|
||||
ctx.ProcessCommand(m, "web.wiki.word", kit.Simple(path.Join(arg[2], arg[1])))
|
||||
ctx.ProcessCommand(m, WEB_WIKI_WORD, kit.Simple(path.Join(arg[2], arg[1])))
|
||||
}},
|
||||
mdb.ENGINE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy("source", path.Join(arg[2], arg[1]))
|
||||
m.Cmdy(ssh.SOURCE, path.Join(arg[2], arg[1]))
|
||||
}},
|
||||
TEMPLATE: {Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Echo(`chapter "hi"`)
|
||||
}},
|
||||
}, PlugAction(), LangAction()), Hand: func(m *ice.Message, arg ...string) {
|
||||
if len(arg) > 0 && kit.Ext(arg[0]) == m.CommandKey() {
|
||||
m.Cmdy("web.wiki.word", path.Join(ice.SRC, strings.TrimPrefix(arg[0], "src/")))
|
||||
return
|
||||
m.Cmdy(WEB_WIKI_WORD, path.Join(ice.SRC, strings.TrimPrefix(arg[0], "src/")))
|
||||
} else {
|
||||
m.Cmdy(WEB_WIKI_WORD, arg)
|
||||
}
|
||||
m.Cmdy("web.wiki.word", arg)
|
||||
}},
|
||||
})
|
||||
}
|
||||
|
@ -18,17 +18,17 @@ const UPGRADE = "upgrade"
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{Configs: ice.Configs{
|
||||
UPGRADE: {Name: UPGRADE, Help: "升级", Value: kit.Dict(mdb.HASH, kit.Dict(
|
||||
nfs.TARGET, kit.Dict(mdb.LIST, kit.List(mdb.TYPE, ice.BIN, nfs.FILE, "ice.bin")),
|
||||
nfs.SOURCE, kit.Dict(mdb.LIST, kit.List(mdb.TYPE, nfs.TAR, nfs.FILE, "contexts.src.tar.gz")),
|
||||
nfs.TARGET, kit.Dict(mdb.LIST, kit.List(mdb.TYPE, ice.BIN, nfs.FILE, ice.ICE_BIN)),
|
||||
nfs.BINARY, kit.Dict(mdb.LIST, kit.List(mdb.TYPE, nfs.TAR, nfs.FILE, "contexts.bin.tar.gz")),
|
||||
nfs.SOURCE, kit.Dict(mdb.LIST, kit.List(mdb.TYPE, nfs.TAR, nfs.FILE, "contexts.src.tar.gz")),
|
||||
))},
|
||||
}, Commands: ice.Commands{
|
||||
UPGRADE: {Name: "upgrade item=target,source,binary run restart", Help: "升级", Actions: ice.Actions{
|
||||
UPGRADE: {Name: "upgrade item=target,binary,source run restart", Help: "升级", Actions: ice.Actions{
|
||||
cli.RESTART: {Name: "restart", Help: "重启", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Sleep300ms().Go(func() { m.Cmd(ice.EXIT, 1) })
|
||||
m.Go(func() { m.Sleep300ms(ice.EXIT, 1) })
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, arg ...string) {
|
||||
mdb.ZoneSelect(m, kit.Select(cli.SYSTEM, arg, 0)).Tables(func(value ice.Maps) {
|
||||
mdb.ZoneSelect(m, kit.Select(nfs.TARGET, arg, 0)).Tables(func(value ice.Maps) {
|
||||
if value[nfs.FILE] == ice.ICE_BIN { // 程序文件
|
||||
value[nfs.FILE] = kit.Keys(ice.ICE, runtime.GOOS, runtime.GOARCH)
|
||||
defer nfs.Rename(m, value[nfs.FILE], ice.BIN_ICE_BIN)
|
||||
@ -37,7 +37,7 @@ func init() {
|
||||
|
||||
// 下载文件
|
||||
dir := kit.Select(kit.Format(value[nfs.FILE]), value[nfs.PATH])
|
||||
m.Cmd(web.SPIDE, ice.DEV, web.SPIDE_SAVE, dir, web.SPIDE_GET, "/publish/"+kit.Format(value[nfs.FILE]))
|
||||
web.SpideSave(m, dir, "/publish/"+kit.Format(value[nfs.FILE]), nil)
|
||||
switch value[mdb.TYPE] {
|
||||
case ice.BIN:
|
||||
os.Chmod(dir, 0755)
|
||||
@ -46,7 +46,7 @@ func init() {
|
||||
}
|
||||
})
|
||||
if web.ToastSuccess(m); m.Option(ice.EXIT) == ice.TRUE {
|
||||
m.Sleep300ms().Go(func() { m.Cmd(ice.EXIT, 1) })
|
||||
m.Cmd("", cli.RESTART)
|
||||
web.ToastRestart(m)
|
||||
}
|
||||
}},
|
||||
|
@ -45,8 +45,7 @@ func init() {
|
||||
default:
|
||||
switch arg[0] {
|
||||
case ctx.INDEX:
|
||||
m.OptionFields(ctx.INDEX)
|
||||
m.Cmdy(ctx.COMMAND, mdb.SEARCH, ctx.COMMAND, kit.Select("", arg, 1), "")
|
||||
m.Cmdy(ctx.COMMAND, mdb.SEARCH, ctx.COMMAND, ice.OptionFields(ctx.INDEX))
|
||||
default:
|
||||
m.Cmdy(COMPLETE, mdb.FOREACH, arg[1], m.Option(ctx.ACTION))
|
||||
}
|
||||
|
@ -60,12 +60,8 @@ func _webpack_cache(m *ice.Message, dir string, write bool) {
|
||||
return
|
||||
}
|
||||
|
||||
m.Option(nfs.DIR_ROOT, dir)
|
||||
m.Option(nfs.DIR_DEEP, true)
|
||||
m.Option(nfs.DIR_TYPE, nfs.CAT)
|
||||
|
||||
for _, k := range []string{LIB, PANEL, PLUGIN} {
|
||||
m.Cmd(nfs.DIR, k).Sort(nfs.PATH).Tables(func(value ice.Maps) {
|
||||
nfs.DirDeepAll(m, dir, k, func(value ice.Maps) {
|
||||
if kit.Ext(value[nfs.PATH]) == CSS {
|
||||
_webpack_css(m, css, js, value[nfs.PATH])
|
||||
}
|
||||
@ -74,7 +70,7 @@ func _webpack_cache(m *ice.Message, dir string, write bool) {
|
||||
fmt.Fprintln(js)
|
||||
|
||||
for _, k := range []string{LIB, PANEL, PLUGIN} {
|
||||
m.Cmd(nfs.DIR, k).Sort(nfs.PATH).Tables(func(value ice.Maps) {
|
||||
nfs.DirDeepAll(m, dir, k, func(value ice.Maps) {
|
||||
if kit.Ext(value[nfs.PATH]) == JS {
|
||||
_webpack_js(m, js, value[nfs.PATH])
|
||||
}
|
||||
@ -94,7 +90,7 @@ func _webpack_cache(m *ice.Message, dir string, write bool) {
|
||||
return
|
||||
case nfs.JS:
|
||||
default:
|
||||
p = p + "/lib/" + p + ".js"
|
||||
p = path.Join(p, LIB, p+".js")
|
||||
}
|
||||
_webpack_node(m, js, path.Join(ice.REQUIRE, ice.NODE_MODULES, p))
|
||||
})
|
||||
@ -125,11 +121,9 @@ func _webpack_build(m *ice.Message, file string) {
|
||||
<script>%s</script>
|
||||
</body>
|
||||
`,
|
||||
m.Cmdx(nfs.CAT, _volcanos(m, PAGE_INDEX_CSS)),
|
||||
m.Cmdx(nfs.CAT, _volcanos(m, PAGE_CACHE_CSS)),
|
||||
m.Cmdx(nfs.CAT, _volcanos(m, PAGE_INDEX_CSS)), m.Cmdx(nfs.CAT, _volcanos(m, PAGE_CACHE_CSS)),
|
||||
m.Cmdx(nfs.CAT, _volcanos(m, ice.PROTO_JS)), m.Cmdx(nfs.CAT, kit.Keys(file, JS)),
|
||||
m.Cmdx(nfs.CAT, _volcanos(m, PAGE_CACHE_JS)),
|
||||
m.Cmdx(nfs.CAT, _volcanos(m, PAGE_INDEX_JS)),
|
||||
m.Cmdx(nfs.CAT, _volcanos(m, PAGE_CACHE_JS)), m.Cmdx(nfs.CAT, _volcanos(m, PAGE_INDEX_JS)),
|
||||
)
|
||||
}
|
||||
}
|
||||
@ -174,8 +168,8 @@ func init() {
|
||||
}
|
||||
}},
|
||||
}, mdb.HashAction(mdb.SHORT, nfs.PATH, mdb.FIELD, "time,path")), Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(nfs.DIR_DEEP, true)
|
||||
m.Option(nfs.DIR_TYPE, nfs.CAT)
|
||||
m.Option(nfs.DIR_DEEP, ice.TRUE)
|
||||
m.OptionFields(nfs.DIR_WEB_FIELDS)
|
||||
m.Cmdy(nfs.DIR, _volcanos(m, PAGE))
|
||||
m.Cmdy(nfs.DIR, _publish(m, WEBPACK))
|
||||
|
@ -108,9 +108,9 @@ func init() {
|
||||
m.PushAction(web.WEBSITE, mdb.REMOVE)
|
||||
m.Action(mdb.CREATE, mdb.PRUNES)
|
||||
} else {
|
||||
ctx.Toolkit(m, FAVOR, "web.chat.iframe")
|
||||
m.Action(INSTALL, "波浪线", "反引号")
|
||||
ctx.DisplayLocal(m, "")
|
||||
ctx.Toolkit(m, FAVOR, "web.chat.iframe")
|
||||
}
|
||||
}},
|
||||
})
|
||||
|
@ -87,7 +87,7 @@ func init() {
|
||||
m.Push(mdb.NAME, "open")
|
||||
|
||||
default:
|
||||
if strings.HasSuffix(m.Option(mdb.TEXT), " ") {
|
||||
if strings.HasSuffix(m.Option(mdb.TEXT), ice.SP) {
|
||||
m.Push(mdb.NAME, "index")
|
||||
m.Push(mdb.NAME, "action")
|
||||
m.Push(mdb.NAME, "args")
|
||||
|
@ -8,7 +8,7 @@ import (
|
||||
)
|
||||
|
||||
func _shell_show(m *ice.Message, name, text string, arg ...string) {
|
||||
m.Option(OUTPUT, m.Cmdx(cli.SYSTEM, "sh", "-c", m.Option(INPUT, text)))
|
||||
m.Option(OUTPUT, cli.SystemCmds(m, m.Option(INPUT, text)))
|
||||
_wiki_template(m, SHELL, name, text, arg...)
|
||||
}
|
||||
|
||||
|
3
init.go
3
init.go
@ -28,7 +28,8 @@ func (f *Frame) Begin(m *Message, arg ...string) Server {
|
||||
}
|
||||
func (f *Frame) Start(m *Message, arg ...string) bool {
|
||||
m.Cap(CTX_STREAM, strings.Split(m.Time(), SP)[1])
|
||||
m.Cmdy(kit.Keys(MDB, CTX_INIT))
|
||||
m.Cmd(kit.Keys(MDB, CTX_INIT))
|
||||
m.Cmd("cli.runtime", CTX_INIT)
|
||||
m.Cmdy(INIT, arg)
|
||||
|
||||
for _, k := range kit.Split(kit.Select("ctx,log,gdb,ssh", os.Getenv(CTX_DAEMON))) {
|
||||
|
4
meta.go
4
meta.go
@ -242,7 +242,9 @@ func (m *Message) Length() (max int) {
|
||||
func (m *Message) Tables(cbs ...func(value Maps)) *Message {
|
||||
return m.Table(func(index int, value Maps, head []string) {
|
||||
for _, cb := range cbs {
|
||||
cb(value)
|
||||
if cb != nil {
|
||||
cb(value)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -49,12 +49,9 @@ func init() {
|
||||
m.Conf(REPOS, mdb.HASH, "")
|
||||
_repos_insert(m, path.Base(kit.Pwd()), kit.Pwd())
|
||||
m.Cmd(nfs.DIR, ice.USR, "name,path", func(value ice.Maps) { _repos_insert(m, value[mdb.NAME], value[nfs.PATH]) })
|
||||
m.Go(func() {
|
||||
m.Sleep300ms()
|
||||
cli.IsAlpine(m, GIT)
|
||||
cli.IsCentos(m, GIT)
|
||||
cli.IsUbuntu(m, GIT)
|
||||
})
|
||||
cli.IsAlpine(m, GIT)
|
||||
cli.IsCentos(m, GIT)
|
||||
cli.IsUbuntu(m, GIT)
|
||||
m.Config(REPOS, "https://shylinux.com/x")
|
||||
}},
|
||||
mdb.CREATE: {Name: "create repos branch name path", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
|
@ -23,16 +23,13 @@ type compile struct {
|
||||
}
|
||||
|
||||
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.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")
|
||||
})
|
||||
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)
|
||||
|
@ -20,11 +20,8 @@ type compile struct {
|
||||
}
|
||||
|
||||
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")
|
||||
})
|
||||
cli.IsAlpine(m.Message, NPM)
|
||||
cli.IsAlpine(m.Message, NODE, "nodejs")
|
||||
}
|
||||
func (s compile) List(m *ice.Message, arg ...string) {
|
||||
s.Code.Source(m, "", arg...)
|
||||
|
Loading…
x
Reference in New Issue
Block a user