diff --git a/base/cli/runtime.go b/base/cli/runtime.go
index 0b2022c9..dd90c3d7 100644
--- a/base/cli/runtime.go
+++ b/base/cli/runtime.go
@@ -99,6 +99,7 @@ const (
MIPSLE = "mipsle"
GOOS = "GOOS"
LINUX = "linux"
+ MACOS = "macos"
DARWIN = "darwin"
WINDOWS = "windows"
)
diff --git a/base/mdb/search.go b/base/mdb/search.go
index 08a1b4fe..4392ca35 100644
--- a/base/mdb/search.go
+++ b/base/mdb/search.go
@@ -19,8 +19,9 @@ func init() {
func IsSearchForEach(m *ice.Message, arg []string, cb func() []string) bool {
if arg[0] == FOREACH && arg[1] == "" {
if cb != nil {
- args := cb()
- m.PushSearch(TYPE, kit.Select("", args, 0), NAME, kit.Select("", args, 1), TEXT, kit.Select("", args, 2))
+ if args := cb(); len(args) > 0 {
+ m.PushSearch(TYPE, kit.Select("", args, 0), NAME, kit.Select("", args, 1), TEXT, kit.Select("", args, 2))
+ }
}
return true
}
diff --git a/base/nfs/pack.go b/base/nfs/pack.go
index c2d59755..21e19638 100644
--- a/base/nfs/pack.go
+++ b/base/nfs/pack.go
@@ -24,6 +24,17 @@ func init() {
})
}},
mdb.REMOVE: {Hand: func(m *ice.Message, arg ...string) { PackFile.Remove(path.Clean(m.Option(PATH))) }},
+ mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
+ if arg[0] == mdb.FOREACH {
+ OptionFiles(m, PackFile)
+ m.Cmd(DIR, SRC, PATH, kit.Dict(DIR_REG, kit.Format(`.*%s.*\.shy`, arg[1]), DIR_DEEP, ice.TRUE, DIR_TYPE, CAT), func(value ice.Maps) {
+ m.PushSearch(mdb.TYPE, SHY, mdb.NAME, value[PATH])
+ })
+ m.Cmd(DIR, USR, PATH, kit.Dict(DIR_REG, kit.Format(`.*%s.*\.shy`, arg[1]), DIR_DEEP, ice.TRUE, DIR_TYPE, CAT), func(value ice.Maps) {
+ m.PushSearch(mdb.TYPE, SHY, mdb.NAME, value[PATH])
+ })
+ }
+ }},
mdb.IMPORT: {Hand: func(m *ice.Message, arg ...string) {
OptionFiles(m, DiskFile)
Open(m, path.Join(m.Option(PATH), m.Option(FILE)), func(r io.Reader, p string) {
diff --git a/core/code/binpack.go b/core/code/binpack.go
index 1cf1b03f..b7f5ea4e 100644
--- a/core/code/binpack.go
+++ b/core/code/binpack.go
@@ -65,7 +65,7 @@ func _binpack_all(m *ice.Message) {
for _, k := range kit.SortedKey(list) {
v := kit.Select(k, list[k])
m.Cmd(nfs.DIR, nfs.PWD, nfs.PATH, kit.Dict(nfs.DIR_ROOT, v, nfs.DIR_REG, kit.ExtReg(SH, SHY, PY, JS, CSS, HTML))).Table(func(value ice.Maps) {
- if ice.Info.Make.Remote != "shylinux.com/x/contexts" && kit.HasPrefix(k, ice.USR_ICEBERGS) {
+ if ice.Info.Make.Remote != "https://shylinux.com/x/contexts" && kit.HasPrefix(k, ice.USR_ICEBERGS) {
return
}
_binpack_file(m, w, kit.Path(v, value[nfs.PATH]), path.Join(k, value[nfs.PATH]))
diff --git a/core/code/install.go b/core/code/install.go
index c2204b7a..0677391a 100644
--- a/core/code/install.go
+++ b/core/code/install.go
@@ -76,11 +76,9 @@ 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) == "" {
- kit.For([]string{"", "sbin", "bin", "_install/bin"}, func(v string) {
- kit.If(nfs.Exists(m, path.Join(p, v)), func() { m.Option(nfs.PATH, v) })
- })
- }
+ kit.For([]string{"", "sbin", "bin", "_install/bin"}, func(v string) {
+ kit.If(nfs.Exists(m, path.Join(p, v)), func() { m.Option(nfs.PATH, v) })
+ })
m.Cmdy(cli.SYSTEM, nfs.PUSH, path.Join(p, m.Option(nfs.PATH)))
}
func _install_spawn(m *ice.Message, arg ...string) {
diff --git a/core/wiki/spark.go b/core/wiki/spark.go
index 3b597f4e..b322f068 100644
--- a/core/wiki/spark.go
+++ b/core/wiki/spark.go
@@ -4,6 +4,7 @@ import (
"strings"
ice "shylinux.com/x/icebergs"
+ "shylinux.com/x/icebergs/base/cli"
"shylinux.com/x/icebergs/base/lex"
"shylinux.com/x/icebergs/base/mdb"
"shylinux.com/x/icebergs/base/nfs"
@@ -44,6 +45,18 @@ func _spark_md(m *ice.Message, arg ...string) *ice.Message {
func _spark_show(m *ice.Message, name, text string, arg ...string) *ice.Message {
return _wiki_template(m.Options(mdb.LIST, kit.SplitLine(text)), name, name, text, arg...)
}
+func _spark_tabs(m *ice.Message, arg ...string) {
+ m.Echo(`
`)
+ {
+ m.Echo(`
`)
+ {
+ kit.For(arg[1:], func(k, v string) { m.Echo(`
%s
`, k) })
+ }
+ m.Echo(`
`)
+ kit.For(arg[1:], func(k, v string) { m.Cmdy("", arg[0], v) })
+ }
+ m.Echo(`
`)
+}
const (
SHELL = "shell"
@@ -60,6 +73,8 @@ func init() {
}), Hand: func(m *ice.Message, arg ...string) {
if kit.Ext(arg[0]) == "md" {
_spark_md(m, arg...)
+ } else if arg[0] == SHELL && kit.IsIn(kit.Select("", arg, 1), cli.LINUX, cli.MACOS, cli.DARWIN, cli.WINDOWS) {
+ _spark_tabs(m, arg...)
} else {
arg = _name(m, arg)
_spark_show(m, arg[0], strings.TrimSpace(arg[1]), arg[2:]...)
diff --git a/misc/java/compile.go b/misc/java/compile.go
index e7be1ebb..e7f45fc6 100644
--- a/misc/java/compile.go
+++ b/misc/java/compile.go
@@ -1,41 +1 @@
package java
-
-import (
- "strings"
-
- "shylinux.com/x/ice"
- "shylinux.com/x/icebergs/base/cli"
- "shylinux.com/x/icebergs/base/nfs"
- kit "shylinux.com/x/toolkits"
-)
-
-const (
- MVN = "mvn"
- JAVA = "java"
- JAVAC = "javac"
-)
-
-type compile struct {
- ice.Code
- regexp string `data:".*\.java$"`
- linux string `data:"https://mirrors.huaweicloud.com/openjdk/18/openjdk-18_linux-x64_bin.tar.gz"`
- list string `name:"list path auto listScript order install" help:"编译器"`
-}
-
-func (s compile) Init(m *ice.Message) {
- 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) List(m *ice.Message, arg ...string) {
- s.Code.Source(m, "", arg...)
-}
-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(compile{}) }
diff --git a/misc/java/compile.shy b/misc/java/compile.shy
index f3f107d4..e69de29b 100644
--- a/misc/java/compile.shy
+++ b/misc/java/compile.shy
@@ -1,18 +0,0 @@
-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
-
-shell `
-wget https://github.com/Tencent/TencentKona-8/releases/download/8.0.11-GA/TencentKona8.0.11.b2_jdk_linux-x86_64_8u345.tar.gz
-tar xvf TencentKona8.0.11.b2_jdk_linux-x86_64_8u345.tar.gz && cd TencentKona-8.0.11-345/
-
-https://repo.huaweicloud.com/java/jdk/8u202-b08/
-wget https://mirrors.huaweicloud.com/openjdk/18/openjdk-18_linux-x64_bin.tar.gz
-tar xvf openjdk-18_linux-x64_bin.tar.gz && cd jdk-18
-`
-
diff --git a/misc/java/java.go b/misc/java/java.go
new file mode 100644
index 00000000..41c629f1
--- /dev/null
+++ b/misc/java/java.go
@@ -0,0 +1,41 @@
+package java
+
+import (
+ "strings"
+
+ "shylinux.com/x/ice"
+ "shylinux.com/x/icebergs/base/cli"
+ "shylinux.com/x/icebergs/base/nfs"
+ kit "shylinux.com/x/toolkits"
+)
+
+const (
+ MVN = "mvn"
+ JAVA = "java"
+ JAVAC = "javac"
+)
+
+type java struct {
+ ice.Code
+ regexp string `data:"java"`
+ linux string `data:"https://mirrors.huaweicloud.com/openjdk/18/openjdk-18_linux-x64_bin.tar.gz"`
+ list string `name:"list path auto listScript order install" help:"编译器"`
+}
+
+func (s java) Init(m *ice.Message) {
+ 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 java) List(m *ice.Message, arg ...string) {
+ s.Code.Source(m, "", arg...)
+}
+func (s java) 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(java{}) }
diff --git a/misc/java/java.shy b/misc/java/java.shy
new file mode 100644
index 00000000..a6c7b567
--- /dev/null
+++ b/misc/java/java.shy
@@ -0,0 +1,20 @@
+section "java"
+refer `
+官网 https://www.java.com/
+文档 https://docs.oracle.com/javase/tutorial/
+下载 https://repo.huaweicloud.com/java/jdk/8u202-b08/
+源码 https://github.com/openjdk/jdk
+开源 https://openjdk.org/
+`
+field web.code.java.java
+
+shell linux `
+wget https://mirrors.huaweicloud.com/openjdk/18/openjdk-18_linux-x64_bin.tar.gz
+tar xvf openjdk-18_linux-x64_bin.tar.gz && cd jdk-18
+` macos `
+curl -O https://repo.huaweicloud.com/java/jdk/8u202-b08/jdk-8u202-macosx-x64.dmg
+open jdk-8u202-macosx-x64.dmg
+` window `
+wget https://repo.huaweicloud.com/java/jdk/8u202-b08/jdk-8u202-windows-x64.exe
+explore jdk-8u202-windows-x64.exe
+`
diff --git a/misc/node.go b/misc/node.go
new file mode 100644
index 00000000..36775ebc
--- /dev/null
+++ b/misc/node.go
@@ -0,0 +1 @@
+package misc
diff --git a/misc/node/admin.shy b/misc/node/admin.shy
new file mode 100644
index 00000000..afcce899
--- /dev/null
+++ b/misc/node/admin.shy
@@ -0,0 +1,14 @@
+section "admin"
+refer `
+https://www.imooc.com/course/list?c=nodejs
+https://gitee.com/talelin
+https://doc.cms.talelin.com
+http://face.cms.talelin.com
+https://www.imooc.com/video/23022
+https://www.imooc.com/video/23025
+`
+
+shell `
+git clone -b imooc-island https://gitee.com/talelin/lin-cms-vue.git
+git clone -b imooc-island https://gitee.com/talelin/lin-cms-koa.git
+`
diff --git a/misc/node/compile.shy b/misc/node/compile.shy
deleted file mode 100644
index c5f90c19..00000000
--- a/misc/node/compile.shy
+++ /dev/null
@@ -1,12 +0,0 @@
-section "node"
-refer `
-官网 https://nodejs.org/
-文档 https://nodejs.org/docs/latest-v6.x/api/
-源码 https://github.com/nodejs/node
-`
-field web.code.node.compile
-
-shell `
-wget https://mirrors.tencent.com/nodejs-release/v16.15.1/node-v16.15.1-linux-x64.tar.xz
-tar xvf node-v16.15.1-linux-x64.tar.xz && cd node-v16.15.1-linux-x64
-`
diff --git a/misc/node/grpc.shy b/misc/node/grpc.shy
new file mode 100644
index 00000000..160fca89
--- /dev/null
+++ b/misc/node/grpc.shy
@@ -0,0 +1,7 @@
+section "grpc"
+shell `
+cnpm i --save-dev grpc-web
+cnpm i --save-dev google-protobuf
+cnpm i -g protoc-gen-js protoc-gen-grpc-web
+protoc --js_out=import_style=commonjs:./demo/src --grpc-web_out=import_style=commonjs,mode=grpcwebtext:./demo/src ./idl/*.proto
+`
diff --git a/misc/node/compile.go b/misc/node/node.go
similarity index 69%
rename from misc/node/compile.go
rename to misc/node/node.go
index b27b7ebb..85c39ccf 100644
--- a/misc/node/compile.go
+++ b/misc/node/node.go
@@ -11,22 +11,22 @@ const (
NODE = "node"
)
-type compile struct {
+type node struct {
ice.Code
- regexp string `data:".*\.js$"`
+ regexp string `data:"js"`
linux string `data:"https://mirrors.tencent.com/nodejs-release/v16.15.1/node-v16.15.1-linux-x64.tar.xz"`
darwin string `data:"https://mirrors.tencent.com/nodejs-release/v16.15.1/node-v16.15.1-darwin-x64.tar.gz"`
- list string `name:"list path auto xterm listScript order install" help:"编译器"`
+ list string `name:"list path auto xterm listScript order install" help:"node"`
}
-func (s compile) Init(m *ice.Message) {
+func (s node) Init(m *ice.Message) {
cli.IsAlpine(m.Message, NPM)
cli.IsAlpine(m.Message, NODE, "nodejs")
}
-func (s compile) List(m *ice.Message, arg ...string) {
+func (s node) List(m *ice.Message, arg ...string) {
s.Code.Source(m, "", arg...)
}
-func (s compile) Xterm(m *ice.Message, arg ...string) {
+func (s node) Xterm(m *ice.Message, arg ...string) {
s.Code.Xterm(m, []string{mdb.TYPE, NODE}, arg...)
}
-func init() { ice.CodeCtxCmd(compile{}) }
+func init() { ice.CodeCtxCmd(node{}) }
diff --git a/misc/node/node.shy b/misc/node/node.shy
new file mode 100644
index 00000000..fa631e4e
--- /dev/null
+++ b/misc/node/node.shy
@@ -0,0 +1,28 @@
+section "node"
+refer `
+官网 https://nodejs.org/
+源码 https://github.com/nodejs/node
+文档 https://nodejs.org/docs/latest-v6.x/api/
+`
+
+field web.code.node.node
+
+shell linux `
+wget https://mirrors.tencent.com/nodejs-release/v16.15.1/node-v16.15.1-linux-x64.tar.xz
+tar xvf node-v16.15.1-linux-x64.tar.xz && cd node-v16.15.1-linux-x64
+` macos `
+curl -O https://mirrors.tencent.com/nodejs-release/v16.15.1/node-v16.15.1-darwin-x64.tar.xz
+tar xvf node-v16.15.1-darwin-x64.tar.xz && cd node-v16.15.1-darwin-x64
+` windows `
+http://mirrors.tencent.com/nodejs-release/v16.15.1/node-v16.15.1-x64.msi
+`
+
+shell `
+./bin/node
+`
+
+source npm.shy
+source vue.shy
+source grpc.shy
+source admin.shy
+source vscode.shy
diff --git a/misc/node/npm.shy b/misc/node/npm.shy
new file mode 100644
index 00000000..02f7bacf
--- /dev/null
+++ b/misc/node/npm.shy
@@ -0,0 +1,4 @@
+section "npm"
+shell `
+./bin/npm install -g cnpm --registry=https://registry.npm.taobao.org
+`
diff --git a/misc/node/vscode.shy b/misc/node/vscode.shy
new file mode 100644
index 00000000..17d9ebf0
--- /dev/null
+++ b/misc/node/vscode.shy
@@ -0,0 +1,13 @@
+section "vscode"
+refer `
+官网 https://code.visualstudio.com
+文档 https://code.visualstudio.com/docs
+`
+shell linux `
+
+` macos `
+https://az764295.vo.msecnd.net/stable/b3e4e68a0bc097f0ae7907b217c1119af9e03435/VSCode-darwin-universal.zip
+https://vscode.cdn.azure.cn/stable/b3e4e68a0bc097f0ae7907b217c1119af9e03435/VSCode-darwin-universal.zip
+` windows `
+
+`
diff --git a/misc/node/vue.shy b/misc/node/vue.shy
index 5ab9ac30..defcd4b9 100644
--- a/misc/node/vue.shy
+++ b/misc/node/vue.shy
@@ -4,3 +4,9 @@ refer `
源码 https://github.com/vuejs/vue
入门 https://vuejs.org/guide/quick-start.html
`
+
+shell `
+cnpm install -g @vue/cli
+vue create demo && cd demo
+vue serve
+`