Giter VIP home page Giter VIP logo

loverocks's Introduction

LOVEROCKS

LÖVERocks is a CLI wrapper around Luarocks that teaches your LÖVE projects how to download and use standard Luarocks packages.

Installing

To install LÖVERocks you'll first need a copy of Luarocks to host it. Luarocks should itself use either Lua 5.1 or Luajit (because that's what LÖVE itself uses) and it should be relatively up-to-date, which as of writing means either Luarocks 2.3.0 or 2.4.0. Note that luarocks 3 is not yet supported but is being actively worked on.

If you're on Windows, the official package works. Notably, Lua For Windows does not work: its Luarocks version is too old.

MacOS users can use brew:

# brew install lua51

This will install both Lua 5.1 and an appropriate Luarocks version.

Linux users should check their package managers. On Ubuntu/Debian, luarocks will work, on Arch Linux the package is called luarocks5.1 instead.

Once you have that, installing LÖVERocks is easy. Just run:

$ luarocks install loverocks

and make sure the directory you installed to is in your $PATH and you should be good to go.

Linux is the primary development platform for loverocks. Windows seems to work, although the test suite still mostly fails, and I've heard that Mac OS seems to work as well. Any issue reports or patches /w/r/t porting would be greatly appreciated.

Using

The LÖVErocks CLI tool is named loverocks. You can learn more about the options and commands it supports by running:

$ loverocks help

To create a new LÖVERocks-managed project, use:

$ loverocks new my-project

This will install the necessary shims and config files into my-project/. This includes:

  • A rocks/ directory to store your modules.

  • A conf.lua, which is configured to add your rocks modules to the search path. You can always comment out

    require 'rocks' ()

    to disable LOVERocks and only use local files, and uncomment it to bring it back.

If you already have a LÖVE project you'd like to manage with Luarocks, just add these lines to your conf.lua instead:

if love.filesystem then
    require 'rocks' ()
end

function love.conf(t)
    t.dependencies = {
    }
end

and LÖVErocks will automatically install your rocks folder for you. If you'd like to customize your install more than that an extended example is also available.

Now you can start working on your project. Lets say you decide you need to use dkjson in your project. To install it, all you need to do is add dkjson to your dependencies table, like so:

function love.conf(t)
    t.dependencies = { "dkjson ~> 2" }
end

and then run

$ loverocks deps

Now you have the latest possible version of dkjson 2, bugfixes included. You can use it like any other top-level module, with

local json = require 'dkjson'

This does not complicate sharing your game, either. Since all modules are stored inside your project folder, and external modules are explicitly disabled, you can continue packaging your game the way you always have:

$ loverocks purge
$ loverocks deps
$ zip -r my-project.love *

will refresh your package cache and install everything, rocks modules included, into my-project.love.

Libraries

If you are a library writer, good news! You do not have to do anything special to support LÖVERocks. Just follow the Luarocks documentation and you should be fine. Just remember, if you depend on LÖVE modules in your code, be sure to make that explicit. For example, if you support LÖVE 0.10 and 11.0, use the dependency string:

    "love >= 0.10, < 12.0"

and LÖVERocks will automatically check that for you.

Known Issues

  • Even though LÖVERocks can install and load native libraries, like for example luafilesystem, there isn't a recommended way (yet) to package them with your application. They are installed at rocks/lib/lua/5.1/ if you'd like to get your hands dirty.

Testing

LÖVERocks uses busted to test. Install it using

$ luarocks install busted

In addition, a mock Luarocks repository is necessary to keep the tests from touching the network. use

$ git clone https://github.com/alloyed/loverocks-repo
$ ./loverocks-repo/make-test-repo.sh

to generate it. If the script is broken for you (sorry!) or you're on Windows, a zipped repository is also available.

To use it:

$ wget http://alloyed.me/loverocks/loverocks-test-repo.zip
$ unzip loverocks-test-repo.zip

LICENSE

Copyright (c) 2016, Kyle McLamb [email protected] under the MIT License

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

loverocks's People

Contributors

alloyed avatar ludwikjaniuk avatar pablomayobre avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

loverocks's Issues

module 'luarocks.cfg' not found

I installed loverocks and attempted to create a new project (actually, I tried running it with --help and -h first to try to understand it better first), and I continually get the same error:

/usr/bin/lua5.1: /usr/local/share/lua/5.1/loverocks/unzip.lua:26: module 'luarocks.cfg' not found:No LuaRocks module found for luarocks.cfg
	no field package.preload['luarocks.cfg']
	no file '/usr/local/share/lua/5.1/luarocks/cfg.lua'
	no file '/usr/local/share/lua/5.1/luarocks/cfg/init.lua'
	no file './luarocks/cfg.lua'
	no file '/usr/local/lib/lua/5.1/luarocks/cfg.lua'
	no file '/usr/local/lib/lua/5.1/luarocks/cfg/init.lua'
	no file '/usr/share/lua/5.1/luarocks/cfg.lua'
	no file '/usr/share/lua/5.1/luarocks/cfg/init.lua'
	no file '/home/tangent/.luarocks/share/lua/5.1/luarocks/cfg.lua'
	no file '/home/tangent/.luarocks/share/lua/5.1/luarocks/cfg/init.lua'
	no file '/usr/local/lib/lua/5.1/luarocks/cfg.so'
	no file './luarocks/cfg.so'
	no file '/usr/lib/x86_64-linux-gnu/lua/5.1/luarocks/cfg.so'
	no file '/usr/lib/lua/5.1/luarocks/cfg.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
	no file '/home/tangent/.luarocks/lib/lua/5.1/luarocks/cfg.so'
	no file '/usr/local/lib/lua/5.1/luarocks.so'
	no file './luarocks.so'
	no file '/usr/lib/x86_64-linux-gnu/lua/5.1/luarocks.so'
	no file '/usr/lib/lua/5.1/luarocks.so'
	no file '/usr/local/lib/lua/5.1/loadall.so'
	no file '/home/tangent/.luarocks/lib/lua/5.1/luarocks.so'
stack traceback:
	[C]: in function 'require'
	/usr/local/share/lua/5.1/loverocks/unzip.lua:26: in main chunk
	[C]: in function 'require'
	/usr/local/share/lua/5.1/loverocks/loadconf.lua:13: in main chunk
	[C]: in function 'require'
	/usr/local/share/lua/5.1/loverocks/love-versions.lua:1: in main chunk
	[C]: in function 'require'
	/usr/local/share/lua/5.1/loverocks/commands/new.lua:4: in main chunk
	[C]: in function 'require'
	/usr/local/share/lua/5.1/loverocks/commands.lua:19: in main chunk
	[C]: in function 'require'
	/usr/local/share/lua/5.1/loverocks/main.lua:2: in main chunk
	[C]: in function 'require'
	...b/luarocks/rocks-5.1/loverocks/0.2.1-1/bin/loverocks:2: in main chunk
	[C]: ?

Dependency importing

Sometimes you want to patch a dependency
The way to do this with minimal hassle is to copy the modules you want to change into your main folder, so you can revision control it and keep loverocks from touching it. (you can also vendor the dependency but that's a lot of bookwork for something that might only get used in one project)
it'd be nice if loverocks could:

  1. do the copying step for you
  2. pin the version it copied so you don't accidentally update only half the module

Remove dependency on luafilesystem

This is the only native binary needed to install loverocks, and windows users may/may not have a compiler installed
afaik it's only used to handle templates, which we can just as easily hardcode.

Dependency freezing

Analogous to pip freeze.
Open questions:
Should there be a defined freezefile location that gets looked for, same as conf.lua?
In the case of scm rocks, should hashes be pinned? How would that be implemented?
Should a freezefile include repository info?
Should loverocks deps prefer a freezefile if one exists or should it get its own command (maybe even xargs loverocks install)?

deps.run accept dependencies in place of conf

deps.run could potentially accept a list of dependencies instead of a conf table. This would be as easy as checking if the table is an array containing strings (there is a schema checking library already in this repository).

This would make it easier to use as a library.

deps.run({ -- Dependency List
  "bump ~> 3",   -- install bump.lua version 3
  "dkjson >= 2", -- install a version of dkjson greater than 2.0
  "repler",      -- install any version of repler, including SCM versions
}, { -- Arguments
  name = "package name", -- Currently provided by t.identity
  from = { -- Currently provided by t.rocks_servers
    "http://alloyed.me/shared/rocks" ,
    "http://luarocks.org"
  },
  tree = "my-rocks-folder", -- Currently provided by t.rocks_tree
  --All the other args still apply (ie: server and only-server)
})

Note that this additional arguments are only available through the library and not exposed to the CLI (although name and tree could)

64-bit luarocks on windows?

By default, the built-in lua that luarocks provides is 32-bit. LOVE can either be 32-bit or 64-bit, so there's a chance (hi) that your LOVE game and your loverocks install have different architectures.
We should probably do something about that ¯_(ツ)_/¯

loverocks new fail due to nil value

I have lua 5.1.5 installed on MxLinux.
I am using love 11.3.

The error outputed is:

Using template "love"
/usr/bin/lua5.1: [string "etlua"]:15: attempt to index global 'versions' (a nil value)
stack traceback:
[string "etlua"]:15: in main chunk
(tail call): ?
/home/anthony/.luarocks/share/lua/5.1/etlua.lua:236: in function </home/anthony/.luarocks/share/lua/5.1/etlua.lua:234>
(tail call): ?
...thony/.luarocks/share/lua/5.1/loverocks/template.lua:31: in function 'apply'
...y/.luarocks/share/lua/5.1/loverocks/commands/new.lua:29: in function <...y/.luarocks/share/lua/5.1/loverocks/commands
/new.lua:23>
(tail call): ?
...s/lib/luarocks/rocks/loverocks/0.2.1-1/bin/loverocks:3: in main chunk
[C]: ?

Support packed games

possible api

$ loverocks --file game.love deps
## install x, y, z to game's savedir
$ loverocks --file game.love list
x
y
z

This could be used to build native modules for your platform when the .love creator hasn't supplied them.

`loverocks init` fails with not finding `templates`

--- LOVE/act-rpg ‹master* ?› » loverocks init
Found LOVE version 0.9.2
ERROR: file 'templates/love9' not found:
    could not open LuaRocks manifest for /home/bb010g/.luarocks
    no file '/home/bb010g/.luarocks/share/lua/5.1/loverocks/templates/love9'
    no file '/home/bb010g/.luarocks/share/lua/5.1/templates/love9'
    no file '/home/bb010g/.luarocks/share/lua/templates/love9'
    no file '/home/bb010g/.luarocks/share/templates/love9'
    no file '/home/bb010g/.luarocks/templates/love9'
    no file '/home/bb010g/templates/love9'
    no file '/home/templates/love9'
    no file '/home/bb010g/.local/share/templates/love9'
    no file '/usr/local/share/templates/love9'
    no file '/usr/share/templates/love9'
    templates/love9: No such file or directory

Using the latest Git. The directory is at ~/.luarocks/lib/luarocks/rocks-5.3/loverocks/scm-0/templates/.

public API?

loverocks is already about 80% there. An example from the test files:

local Purge   = require 'loverocks.commands.purge'
local New     = require 'loverocks.commands.new'
local Install = require 'loverocks.commands.install'

New.run {
    project      = "my-project",
    template     = "love",
    love_version = "0.10.1",
}

lfs.chdir("my-project")

Install.run {
    packages = {"inspect"},
    only_server = cwd .. "/test-repo"
}

Purge.run {}

Problems:

  • global state: current working directory, the logger
  • config loading happens at the command level for reasons I've forgotten, try to hoist it up
  • loverocks.api is already taken by my loverocks <-> luarocks layer. oops.

remove stale dependencies

this would either be a flag to purge, or a custom command (clean?).
it might make sense to remove purge, or replace it with rm -rf rocks/.
although having it adds a sense of discoverability, you can read the help and know how to empty a tree

Support for Lua 5.3

Hi,

I'm trying to get this working with Lua 5.3. How would you feel about adding something like this to patch support for setfenv?

I realise this may not be the only issue with supporting 5.3 but it's the first thing that's come up.

Thanks

Cannot Install loverocks on Windows

I cannot install loverocks.

I have Visual Studio 2015 (which is probably the problem) in Windows 8.1 and i'm using the VS2015 Developer Command Prompt (as Administrator) to install loverocks.
I installed lua and luarocks using Lua for Windows (if that helps)

The error i get is:

Microsoft (R) Incremental Linker Version 14.00.23918.0
Copyright (C) Microsoft Corporation.  All rights reserved.

rclauncher.obj : error LNK2019: unresolved external symbol _printf referenced in function _report
rclauncher.obj : error LNK2019: unresolved external symbol ___iob_func referenced in function _report
bin\loverocks.exe : fatal error LNK1120: 2 unresolved externals

Error: Build error: Build error in wrapper binaries

Is there something i missed?

Improving the getting started story for new users

I'm just wondering if it might be putting a warning in the installation section that the latest version of loverocks won't install unless you're using lua version 5.1, and if you're using a later version of lua (like version 5.3) you'll end up with loverocks version 0.2.0. Like as a new users it's not really something you expect, and before I figured out I went though a bit of a wild goose chase.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.