mirror of
https://shylinux.com/x/icebergs
synced 2025-04-26 09:34:05 +08:00
opt auto_version
This commit is contained in:
parent
fbf24e1100
commit
b7bc327311
@ -61,7 +61,6 @@ func _serve_main(m *ice.Message, w http.ResponseWriter, r *http.Request) bool {
|
||||
if msg.W, msg.R = w, r; strings.Contains(r.Header.Get("User-Agent"), "curl") {
|
||||
Render(msg, ice.RENDER_DOWNLOAD, kit.Path(m.Conf(SERVE, "meta.intshell.path"), m.Conf(SERVE, "meta.intshell.index")))
|
||||
} else {
|
||||
m.Debug("what %v %v", r.URL.Path, ice.BinPack)
|
||||
if ice.DumpBinPack(w, r.URL.Path, func(name string) { RenderType(w, name, "") }) {
|
||||
return false
|
||||
}
|
||||
|
@ -5,10 +5,8 @@ import (
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
"github.com/shylinux/icebergs/base/mdb"
|
||||
"github.com/shylinux/icebergs/base/nfs"
|
||||
"github.com/shylinux/icebergs/base/web"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
)
|
||||
@ -21,6 +19,31 @@ func _autogen_script(m *ice.Message, dir string) {
|
||||
func _autogen_source(m *ice.Message, name string) {
|
||||
m.Cmd("nfs.file", "append", "src/main.shy", "\n", `source `+name+"/"+name+".shy", "\n")
|
||||
}
|
||||
func _autogen_version(m *ice.Message) {
|
||||
m.Cmdy(nfs.SAVE, "src/version.go", kit.Format(`package main
|
||||
|
||||
import (
|
||||
"github.com/shylinux/icebergs"
|
||||
)
|
||||
|
||||
func init() {
|
||||
ice.Info.Build.Time = "%s"
|
||||
ice.Info.Build.Hash = "%s"
|
||||
ice.Info.Build.Remote = "%s"
|
||||
ice.Info.Build.Branch = "%s"
|
||||
ice.Info.Build.Version = "%s"
|
||||
ice.Info.Build.HostName = "%s"
|
||||
ice.Info.Build.UserName = "%s"
|
||||
}
|
||||
`,
|
||||
m.Time(),
|
||||
strings.TrimSpace(m.Cmdx(cli.SYSTEM, "git", "log", "-n1", `--pretty=%H`)),
|
||||
strings.TrimSpace(m.Cmdx(cli.SYSTEM, "git", "config", "remote.origin.url")),
|
||||
strings.TrimSpace(m.Cmdx(cli.SYSTEM, "git", "rev-parse", "--abbrev-ref", "HEAD")),
|
||||
strings.TrimSpace(m.Cmdx(cli.SYSTEM, "git", "describe", "--tags")),
|
||||
ice.Info.HostName, ice.Info.UserName,
|
||||
))
|
||||
}
|
||||
func _autogen_index(m *ice.Message, dir string, from string, ctx string) {
|
||||
list := []string{}
|
||||
|
||||
@ -73,7 +96,7 @@ const AUTOGEN = "autogen"
|
||||
func init() {
|
||||
Index.Merge(&ice.Context{
|
||||
Commands: map[string]*ice.Command{
|
||||
AUTOGEN: {Name: "autogen path auto create binpack script", Help: "生成", Action: map[string]*ice.Action{
|
||||
AUTOGEN: {Name: "autogen path auto create binpack", Help: "生成", Action: map[string]*ice.Action{
|
||||
mdb.CREATE: {Name: "create main=src/main.go@key name=hi@key from=usr/icebergs/misc/bash/bash.go@key", Help: "模块", Hand: func(m *ice.Message, arg ...string) {
|
||||
if p := path.Join("src", m.Option("name"), m.Option("name")+".shy"); !kit.FileExists(p) {
|
||||
_autogen_script(m, p)
|
||||
@ -87,6 +110,10 @@ func init() {
|
||||
m.Cmdy(cli.SYSTEM, "make")
|
||||
m.Option(ice.MSG_PROCESS, ice.PROCESS_INNER)
|
||||
}},
|
||||
BINPACK: {Name: "binpack", Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
||||
_autogen_version(m)
|
||||
m.Cmdy(BINPACK, mdb.CREATE)
|
||||
}},
|
||||
mdb.INPUTS: {Name: "inputs", Help: "补全", Hand: func(m *ice.Message, arg ...string) {
|
||||
switch arg[0] {
|
||||
case "main":
|
||||
@ -102,16 +129,6 @@ func init() {
|
||||
m.RenameAppend("path", arg[0])
|
||||
}
|
||||
}},
|
||||
BINPACK: {Name: "binpack", Help: "打包", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Cmdy(BINPACK, mdb.CREATE)
|
||||
}},
|
||||
mdb.SCRIPT: {Name: "script", Help: "脚本", Hand: func(m *ice.Message, arg ...string) {
|
||||
miss := "etc/miss.sh"
|
||||
if _, e := os.Stat(miss); os.IsNotExist(e) {
|
||||
m.Cmd(nfs.SAVE, miss, m.Conf(web.DREAM, "meta.miss"))
|
||||
}
|
||||
m.Echo(miss)
|
||||
}},
|
||||
}, Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
if m.Option(nfs.DIR_ROOT, "src"); len(arg) == 0 || strings.HasSuffix(arg[0], "/") {
|
||||
m.Cmdy(nfs.DIR, kit.Select("./", arg, 0))
|
||||
|
@ -3,6 +3,7 @@ package code
|
||||
import (
|
||||
ice "github.com/shylinux/icebergs"
|
||||
"github.com/shylinux/icebergs/base/cli"
|
||||
"github.com/shylinux/icebergs/base/mdb"
|
||||
"github.com/shylinux/icebergs/base/nfs"
|
||||
kit "github.com/shylinux/toolkits"
|
||||
|
||||
@ -40,8 +41,8 @@ func init() {
|
||||
)},
|
||||
},
|
||||
Commands: map[string]*ice.Command{
|
||||
PUBLISH: {Name: "publish path auto publish ish ice can", Help: "发布", Action: map[string]*ice.Action{
|
||||
"publish": {Name: "publish file", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
PUBLISH: {Name: "publish path auto create ish ice can", Help: "发布", Action: map[string]*ice.Action{
|
||||
mdb.CREATE: {Name: "create file", Help: "添加", Hand: func(m *ice.Message, arg ...string) {
|
||||
_publish_file(m, m.Option(kit.MDB_FILE))
|
||||
}},
|
||||
"contexts": {Name: "contexts", Help: "环境", Hand: func(m *ice.Message, arg ...string) {
|
||||
@ -84,6 +85,11 @@ func init() {
|
||||
}
|
||||
m.SortTimeR(kit.MDB_TIME)
|
||||
m.Cmdy(PUBLISH, "contexts", "base")
|
||||
m.PushAction(mdb.REMOVE)
|
||||
}},
|
||||
mdb.REMOVE: {Name: "remove", Help: "删除", Hand: func(m *ice.Message, arg ...string) {
|
||||
p := m.Option(cli.CMD_DIR, m.Conf(PUBLISH, kit.META_PATH))
|
||||
os.Remove(path.Join(p, m.Option(kit.MDB_FILE)))
|
||||
}},
|
||||
"can": {Name: "can", Help: "火山架", Hand: func(m *ice.Message, arg ...string) {
|
||||
m.Option(nfs.DIR_DEEP, true)
|
||||
|
@ -52,7 +52,7 @@ var Index = &ice.Context{Name: TMUX, Help: "工作台",
|
||||
Commands: map[string]*ice.Command{
|
||||
ice.CTX_INIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Load()
|
||||
m.Watch(web.DREAM_CREATE, m.Prefix(SESSION))
|
||||
// m.Watch(web.DREAM_CREATE, m.Prefix(SESSION))
|
||||
}},
|
||||
ice.CTX_EXIT: {Hand: func(m *ice.Message, c *ice.Context, cmd string, arg ...string) {
|
||||
m.Save()
|
||||
|
Loading…
x
Reference in New Issue
Block a user