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 (
|
const (
|
||||||
PWD = "./"
|
PWD = "./"
|
||||||
SRC = "src/"
|
SRC = "src/"
|
||||||
BIN = "bin/"
|
BIN = "bin/"
|
||||||
USR = "usr/"
|
USR = "usr/"
|
||||||
REQUIRE = "/require/"
|
USR_INSTALL = "usr/install/"
|
||||||
|
REQUIRE = "/require/"
|
||||||
|
|
||||||
TYPE_ALL = "all"
|
TYPE_ALL = "all"
|
||||||
TYPE_BIN = "bin"
|
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.REMOVE: {Hand: func(m *ice.Message, arg ...string) { PackFile.Remove(path.Clean(m.Option(PATH))) }},
|
||||||
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
mdb.SEARCH: {Hand: func(m *ice.Message, arg ...string) {
|
||||||
if arg[0] == mdb.FOREACH {
|
if arg[0] == mdb.FOREACH && arg[1] != "" {
|
||||||
OptionFiles(m, PackFile)
|
m.Cmd(DIR, SRC, PATH, kit.Dict(DIR_REG, arg[1], DIR_DEEP, ice.TRUE, DIR_TYPE, CAT), func(value ice.Maps) {
|
||||||
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) {
|
if strings.HasPrefix(value[PATH], ice.SRC_TEMPLATE) {
|
||||||
m.PushSearch(mdb.TYPE, SHY, mdb.NAME, value[PATH])
|
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) {
|
OptionFiles(m, PackFile)
|
||||||
m.PushSearch(mdb.TYPE, SHY, mdb.NAME, value[PATH])
|
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) {
|
Open(m, p, func(r io.Reader) {
|
||||||
for {
|
for {
|
||||||
switch kit.Ext(p) {
|
switch kit.Ext(p) {
|
||||||
case "tgz":
|
case TGZ:
|
||||||
p = kit.Keys(kit.TrimExt(p, kit.Ext(p)), TAR, GZ)
|
p = kit.Keys(kit.TrimExt(p, kit.Ext(p)), TAR, GZ)
|
||||||
case GZ:
|
case GZ:
|
||||||
if f, e := gzip.NewReader(r); m.Warn(e, ice.ErrNotValid, p) {
|
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 (
|
const (
|
||||||
GZ = "gz"
|
XZ = "xz"
|
||||||
|
GZ = "gz"
|
||||||
|
TGZ = "tgz"
|
||||||
)
|
)
|
||||||
const TAR = "tar"
|
const TAR = "tar"
|
||||||
|
|
||||||
|
@ -1,30 +1,34 @@
|
|||||||
package node
|
package node
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"path"
|
||||||
|
|
||||||
"shylinux.com/x/ice"
|
"shylinux.com/x/ice"
|
||||||
"shylinux.com/x/icebergs/base/cli"
|
"shylinux.com/x/icebergs/base/cli"
|
||||||
"shylinux.com/x/icebergs/base/mdb"
|
"shylinux.com/x/icebergs/base/mdb"
|
||||||
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
|
kit "shylinux.com/x/toolkits"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const NODE = "node"
|
||||||
NPM = "npm"
|
|
||||||
NODE = "node"
|
|
||||||
)
|
|
||||||
|
|
||||||
type node struct {
|
type node struct {
|
||||||
ice.Code
|
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"`
|
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) {
|
func (s node) Init(m *ice.Message) {
|
||||||
cli.IsAlpine(m.Message, NPM)
|
|
||||||
cli.IsAlpine(m.Message, NODE, "nodejs")
|
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) {
|
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) {
|
func (s node) Xterm(m *ice.Message, arg ...string) {
|
||||||
s.Code.Xterm(m, []string{mdb.TYPE, NODE}, arg...)
|
s.Code.Xterm(m, []string{mdb.TYPE, NODE}, arg...)
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
chapter "node"
|
||||||
section "node"
|
section "node"
|
||||||
refer `
|
refer `
|
||||||
官网 https://nodejs.org/
|
官网 https://nodejs.org/
|
||||||
|
@ -2,14 +2,20 @@ package node
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"shylinux.com/x/ice"
|
"shylinux.com/x/ice"
|
||||||
|
"shylinux.com/x/icebergs/base/cli"
|
||||||
"shylinux.com/x/icebergs/base/nfs"
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const NPM = "npm"
|
||||||
|
|
||||||
type npm struct {
|
type npm struct {
|
||||||
ice.Code
|
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) {
|
func (s npm) List(m *ice.Message) {
|
||||||
m.Cmdy(nfs.DIR, ice.USR_MODULES)
|
m.Cmdy(nfs.DIR, ice.USR_MODULES)
|
||||||
}
|
}
|
||||||
|
@ -2,3 +2,4 @@ section "npm"
|
|||||||
shell `
|
shell `
|
||||||
./bin/npm install -g cnpm --registry=https://registry.npm.taobao.org
|
./bin/npm install -g cnpm --registry=https://registry.npm.taobao.org
|
||||||
`
|
`
|
||||||
|
field web.code.node.npm
|
||||||
|
@ -1,14 +1,17 @@
|
|||||||
package node
|
package node
|
||||||
|
|
||||||
import "shylinux.com/x/ice"
|
import (
|
||||||
|
"shylinux.com/x/ice"
|
||||||
|
"shylinux.com/x/icebergs/base/nfs"
|
||||||
|
)
|
||||||
|
|
||||||
type vue struct {
|
type vue struct {
|
||||||
ice.Code
|
ice.Code
|
||||||
list string `name:"list auto" help:"服务框架"`
|
list string `name:"list path auto" help:"vue"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s vue) List(m *ice.Message) {
|
func (s vue) List(m *ice.Message) {
|
||||||
|
m.Cmdy(nfs.DIR, nfs.USR)
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() { ice.CodeCtxCmd(vue{}) }
|
func init() { ice.CodeCtxCmd(vue{}) }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user