luarocks 牛刀小试

2019-09-25 23:34:56
收藏数:1
阅读数:259
评论数:0

图片

luarocks 安装

macOS 环境安装

brew install luarocks

linux 环境安装

sudo apt install build-essential libreadline-dev
wget https://luarocks.org/releases/luarocks-3.2.0.tar.gz
tar zxpf luarocks-3.2.0.tar.gz
cd luarocks-3.2.0
./configure (这里会检测 lua 是否安装,没有安装会失败)
make build
make install

windows 环境安装

luarocks 使用

初始化项目

新建一个rockspec文件,文件命名规则 {{name}}-{{version}}-{{rockspec提交更新次数}}.rockspec 如:nana-0.0.5-3.rockspec

package = "nana"
version = "0.0.5-3"
source = {
   url = "git://github.com/horan-geeker/nana",
   tag = "v0.5.0",
}
description = {
   summary = "http api server framework",
   detailed = [[
        Nana is a http restful api framework written in Lua which need be used in openresty platform and it's designed reference Laravel framework styles
   ]],
   homepage = "https://github.com/horan-geeker/nana",
   license = "MIT/X11"
}
dependencies = {
   "lua >= 5.1, < 5.4",
}
build = {
    type = "builtin",
    modules = {
        ["bootstrap"] = "bootstrap.lua"
    }
}

其中

  • package 同 {{name}}
  • version 同 {{version}}
  • source 里 url 是项目 github 的地址,tag 是项目的 tag
  • description 是项目说明,在 luarocks 网站里会带着链接和说明文案

写好说明书之后可以操作上传 luarocks upload nana-0.0.5-3.rockspec