Open rvalle opened 4 years ago
Maybe my mistake is to expect a similar experience to nodejs npm package.json
I'm looking for the same, a sample github repo set up with rockspecs would be invaluable. Let me know what you find!
@insanetheta I have made some progress
Here is what I have learned, that seems to be working for me:
mkdir project
cd project
luarocks init
this will setup some of the project structure but not all, you also need to:
mkdir src spec
The only test suite that seems to work is busted, you have to put that into your rockfile and also change the spec version to 3.0
The busted test suite is the only one I managed to make work, but it is nice that reads like mocha http://olivinelabs.com/busted/
I think all your test files need to be called xxxx_spec.lua and be into the spec directory.
You will be able to require("mymodule") from the tests, for some magic reason it does work.
Please note that you have to execute the tests as:
./luarocks test
I attach my sample project here:
this is my file tree:
[nodemcu-sample]$ find .
.
./src
./src/hello.lua
./spec
./spec/env_spec.lua
./spec/hello_spec.lua
./nodemcu-sample-dev-1.rockspec
./.gitignore
./lua
./luarocks
this is my rockspec
rockspec_format = "3.0"
package = "nodemcu-sample"
version = "dev-1"
source = {
url = "*** please add URL for source tarball, zip or repository here ***"
}
description = {
homepage = "*** please enter a project homepage ***",
license = "*** please specify a license ***"
}
test = {
type = "busted"
}
build = {
type = "builtin",
modules = {
hello = "src/hello.lua"
}
}
Setting dependencies in the rockspec seems to serve no purpose during development. I cannot find a equivalent to npm install in nodejs, that will download all your dependencies for development. I think this must be only for installing the rockfile after distribution.
It took me a lot of browsing and guessing to find out up till here. Luarocks would definitely benefit from good sample projects.
Hi!
I am new to Lua and new to Luarocks, but I am experience in many other computer languages.
I am looking for an "example project" just to set up mine in a similar way.
I would expect a rockfile with dependencies, code and unit tests
And explanation of the lifecycle:
How to load the dependencies, run de tests, run the application, make the package, and share the package. Similar to what we do with nodejs or maven.
What is the normal development lifefycle like?
I have reviewed the Luarocks documentation but I am still clueless. For example I can see dependences in the rockfile, but how do you download them?, no code sample uses those dependencies or launches tests. I can make the rock, but how to use it?
I see a lot of C makefiles, but that is supposed to be more advanced, isn't it? I am expecting to use only lua to start with.
Can anybody point me to a good project example to get started with?