forked from x/icebergs
add node
This commit is contained in:
parent
746fb79e7c
commit
bd4b8e29c8
@ -128,11 +128,12 @@ func _dir_list(m *ice.Message, root string, dir string, level int, deep bool, di
|
||||
}
|
||||
|
||||
const (
|
||||
PWD = "./"
|
||||
SRC = "src/"
|
||||
BIN = "bin/"
|
||||
USR = "usr/"
|
||||
REQUIRE = "/require/"
|
||||
PWD = "./"
|
||||
SRC = "src/"
|
||||
BIN = "bin/"
|
||||
USR = "usr/"
|
||||
USR_INSTALL = "usr/install/"
|
||||
REQUIRE = "/require/"
|
||||
|
||||
TYPE_ALL = "all"
|
||||
TYPE_BIN = "bin"
|
||||
|
@ -25,13 +25,16 @@ 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])
|
||||
if arg[0] == mdb.FOREACH && arg[1] != "" {
|
||||
m.Cmd(DIR, SRC, PATH, kit.Dict(DIR_REG, arg[1], DIR_DEEP, ice.TRUE, DIR_TYPE, CAT), func(value ice.Maps) {
|
||||
if strings.HasPrefix(value[PATH], ice.SRC_TEMPLATE) {
|
||||
return
|
||||
}
|
||||
m.PushSearch(mdb.TYPE, kit.Ext(value[PATH]), mdb.NAME, path.Base(value[PATH]), mdb.TEXT, 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])
|
||||
OptionFiles(m, PackFile)
|
||||
m.Cmd(DIR, USR, PATH, kit.Dict(DIR_REG, arg[1], DIR_DEEP, ice.TRUE, DIR_TYPE, CAT), func(value ice.Maps) {
|
||||
m.PushSearch(mdb.TYPE, kit.Ext(value[PATH]), mdb.NAME, path.Base(value[PATH]), mdb.TEXT, value[PATH])
|
||||
})
|
||||
}
|
||||
}},
|
||||
|
@ -17,7 +17,7 @@ func _tar_list(m *ice.Message, p string, cb func(*tar.Header, io.Reader, int)) {
|
||||
Open(m, p, func(r io.Reader) {
|
||||
for {
|
||||
switch kit.Ext(p) {
|
||||
case "tgz":
|
||||
case TGZ:
|
||||
p = kit.Keys(kit.TrimExt(p, kit.Ext(p)), TAR, GZ)
|
||||
case GZ:
|
||||
if f, e := gzip.NewReader(r); m.Warn(e, ice.ErrNotValid, p) {
|
||||
@ -49,7 +49,9 @@ func _tar_list(m *ice.Message, p string, cb func(*tar.Header, io.Reader, int)) {
|
||||
}
|
||||
|
||||
const (
|
||||
GZ = "gz"
|
||||
XZ = "xz"
|
||||
GZ = "gz"
|
||||
TGZ = "tgz"
|
||||
)
|
||||
const TAR = "tar"
|
||||
|
||||
|
@ -1,30 +1,34 @@
|
||||
package node
|
||||
|
||||
import (
|
||||
"path"
|
||||
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/mdb"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
kit "shylinux.com/x/toolkits"
|
||||
)
|
||||
|
||||
const (
|
||||
NPM = "npm"
|
||||
NODE = "node"
|
||||
)
|
||||
const NODE = "node"
|
||||
|
||||
type node 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"`
|
||||
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:"node"`
|
||||
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 xterm order install" help:"node"`
|
||||
}
|
||||
|
||||
func (s node) Init(m *ice.Message) {
|
||||
cli.IsAlpine(m.Message, NPM)
|
||||
cli.IsAlpine(m.Message, NODE, "nodejs")
|
||||
}
|
||||
func (s node) Install(m *ice.Message, arg ...string) {
|
||||
s.Code.Install(m, arg...)
|
||||
s.Code.System(m, nfs.USR_INSTALL, nfs.TAR, "xf", path.Base(s.Code.Link(m)))
|
||||
}
|
||||
func (s node) List(m *ice.Message, arg ...string) {
|
||||
s.Code.Source(m, "", arg...)
|
||||
s.Code.Source(m, path.Join(nfs.USR_INSTALL, kit.TrimExt(s.Code.Link(m), "tar.xz")), arg...)
|
||||
}
|
||||
func (s node) Xterm(m *ice.Message, arg ...string) {
|
||||
s.Code.Xterm(m, []string{mdb.TYPE, NODE}, arg...)
|
||||
|
@ -1,3 +1,4 @@
|
||||
chapter "node"
|
||||
section "node"
|
||||
refer `
|
||||
官网 https://nodejs.org/
|
||||
|
@ -2,14 +2,20 @@ package node
|
||||
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/cli"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
)
|
||||
|
||||
const NPM = "npm"
|
||||
|
||||
type npm struct {
|
||||
ice.Code
|
||||
list string `name:"list auto"`
|
||||
list string `name:"list path auto" help:"npm"`
|
||||
}
|
||||
|
||||
func (s npm) Init(m *ice.Message) {
|
||||
cli.IsAlpine(m.Message, NPM)
|
||||
}
|
||||
func (s npm) List(m *ice.Message) {
|
||||
m.Cmdy(nfs.DIR, ice.USR_MODULES)
|
||||
}
|
||||
|
@ -2,3 +2,4 @@ section "npm"
|
||||
shell `
|
||||
./bin/npm install -g cnpm --registry=https://registry.npm.taobao.org
|
||||
`
|
||||
field web.code.node.npm
|
||||
|
@ -1,14 +1,17 @@
|
||||
package node
|
||||
|
||||
import "shylinux.com/x/ice"
|
||||
import (
|
||||
"shylinux.com/x/ice"
|
||||
"shylinux.com/x/icebergs/base/nfs"
|
||||
)
|
||||
|
||||
type vue struct {
|
||||
ice.Code
|
||||
list string `name:"list auto" help:"服务框架"`
|
||||
list string `name:"list path auto" help:"vue"`
|
||||
}
|
||||
|
||||
func (s vue) List(m *ice.Message) {
|
||||
|
||||
m.Cmdy(nfs.DIR, nfs.USR)
|
||||
}
|
||||
|
||||
func init() { ice.CodeCtxCmd(vue{}) }
|
||||
|
Loading…
x
Reference in New Issue
Block a user