Stanley - Git-based package manager for Lua

Showcase your libraries, tools and other projects that help your fellow love users.
Post Reply
wlf2789
Prole
Posts: 7
Joined: Wed Sep 16, 2015 12:07 am
Contact:

Stanley - Git-based package manager for Lua

Post by wlf2789 »

Hi.

I've made a simple tool to save myself some time during development.
It's a local directory git-based package manager written in python.

It's called Stanley.
You can find it here: https://github.com/Wolf2789/Stanley
Currently I've only tested it on Linux and WSL.

How to use it?
I've put everything important inside README so I suggest you check it first.

How it works?
Basically, you put Stanley inside root directory of your project and tell him what libraries to download from different git repositories.
It then creates an "autoload.lua" file under "lib" directory, which can be loaded inside "main.lua" file.
wlf2789 wrote:Contents of "autoload.lua" file should remain untouched, as it's always being overwritten when "./stanley dump" command is issued.
##

One of the main features is that it tries to keep general order of individual packages.
Let's say you've recently added a package that depends on another package you've added earlier.
That's no problem, since Stanley automatically puts dependencies at the top of the list.

There's only one situation that I've not resolved yet:
If a package depends on another package, which in turns depends on the first one, then Stanley might break and fall into infinity loop, because first package depends on the second one, but the second one depends on the first one, but again first one depends on the second and that goes forever.

If that happens to you, then you're probably doing something wrong, because for me there's no logic in this.

##

Another nice feature is that you can easily create package from already existing source code, even if it's not prepared for work with Stanley.

For example:
You've found lua code that suits your needs, but it's not compatible with Stanley.

What can you do in this situation?
Basically:
  1. You create new catalog under "lib" directory and call it somewhat like the source code you're trying to use.
  2. You create "package.yaml" file under this new directory and in the "require" section, you add repository of this source code you're trying to use.
  3. In "entry" section you define how to handle this code. Basically you can create your own "init_or_any_other_file_name.lua" or use built-in global variable registration.
  4. You add your custom path to "require" section inside your "project.yaml" file and issue "./stanley update".
  5. .....? Profit! Newly generated autoload file should contain everything you've specified.
I know it's just a theory, but more practical example can be seen here: https://github.com/Wolf2789/Stanley/tre ... _structure
Look under "lib" directory ;)
I suggest you download everything and issue "./stanley update" and see what happens.

##

If anybody have any questions, feel free to contact with me.
I suggest you write me an e-mail (wolf2789@gmail.com) or catch me on Discord (wlf#4649)
wlf2789
Prole
Posts: 7
Joined: Wed Sep 16, 2015 12:07 am
Contact:

Re: Stanley - Git-based package manager for Lua

Post by wlf2789 »

Hi again.

I've decided to put more info here, because with Stanley I'm trying to mark new routes in Lua development and not everyone may be familiar with this type of work.

Stanley is similar to Composer, which is a package manager for PHP projects and also similar to NPM, which is a package manager for Node.js projects.

You ask me why we need such thing here?
I'll try to answer this question with simple example:
1. Let's say there's a guy called 'Mike' and Mike have created a library for his Lua project, but then he thought, he should share it with others.
2. So Mike decides to put it in his repository on github, so everyone interested in the library could simply download and use it.
3. Now let's say there are dozens of people like Mike. They share their piece of work with other people through github.
4. Now imagine there is another guy called 'Luke' and he found himself some interesting libraries he wants to use in his project.
Most of those libraries have main file which returns library itself, so he just need to add this simple line into his main lua file:

Code: Select all

local library = require('library.path')
5. So he goes to every repository, downloads it, extract to his project, look through code and/or check README for instructions and adds this simple line.
6. But the more libraries he downloads, the more tedious work it becomes.
7. What if he could simply issue single command, which automatically clones git repository and adds those much needed one-line instructions?

This is exactly what Stanley does at this very moment.
By issuing 'stanley require repo/name' you add github repository to your project. You can require as many libraries as you want.
Then you issue 'stanley dump' and Stanley generates autoload file which can be then simply included in main lua file with:

Code: Select all

require('lib.autoload')
Of course all required repositories must contain single file called 'package.yaml' which will instruct Stanley on how to add this code source to autoload file.

If this doesn't convince you, then I think you're simply not ready for bigger thinking like other big minds in the world are.
For example look at 'Laravel' for PHP. It's a massive framework which uses all kinds of other smaller libraries and provides much more functionality to PHP projects.
There are dozens of this kind of projects and many package managers, but I'm suprised no one has thought about it this way.

I hope my intentions are clear and there will be people willing to participate.
User avatar
zorg
Party member
Posts: 3465
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Stanley - Git-based package manager for Lua

Post by zorg »

Okay, so some people might be sold on this, although i'm not certain about a few things...
I've decided to put more info here, because with Stanley I'm trying to mark new routes in Lua development and not everyone may be familiar with this type of work.
I'll admit you can sell the idea pretty nicely, but is this tool really that necessary?

Another thing, one would need to actually write the package.yaml files for all the assumed dozens of libraries one would include, since you know, they wouldn't exist yet; and you're claiming that would take less time and/or effort than just writing the single individual require lines? that seems bogus.

Oh, i also like the fact that i need to have python3 bloat my system as well, when i want to develop a lua thing, but that may very well be just me. :o:
>If this doesn't convince you, then I think you're simply not ready for bigger thinking like other big minds in the world are.
And i'm, of course, just going to ignore the backhanded low-key diss questioning people's intelligence because you apparently think you're the next Steve Jobs pushing out some invaluable new solution to a problem most people never even thought they had... but hey, that might have been just a language difference thing there, who knows... : 3
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
wlf2789
Prole
Posts: 7
Joined: Wed Sep 16, 2015 12:07 am
Contact:

Re: Stanley - Git-based package manager for Lua

Post by wlf2789 »

zorg wrote: Mon Mar 30, 2020 3:46 pm Okay, so some people might be sold on this, although i'm not certain about a few things...
I've decided to put more info here, because with Stanley I'm trying to mark new routes in Lua development and not everyone may be familiar with this type of work.
I'll admit you can sell the idea pretty nicely, but is this tool really that necessary?

Another thing, one would need to actually write the package.yaml files for all the assumed dozens of libraries one would include, since you know, they wouldn't exist yet; and you're claiming that would take less time and/or effort than just writing the single individual require lines? that seems bogus.

Oh, i also like the fact that i need to have python3 bloat my system as well, when i want to develop a lua thing, but that may very well be just me. :o:
>If this doesn't convince you, then I think you're simply not ready for bigger thinking like other big minds in the world are.
And i'm, of course, just going to ignore the backhanded low-key diss questioning people's intelligence because you apparently think you're the next Steve Jobs pushing out some invaluable new solution to a problem most people never even thought they had... but hey, that might have been just a language difference thing there, who knows... : 3
I really appreciate your feedback and totally understand your point :)
Please let me clear some things up.

Answering the first question:
It may not be now that necessary, but people were also skeptical against Composer and NPM when they came out.
If this project succeeds, then it's just a matter of time before people start adding their own 'package.yaml' inside their repos since that's all they have to do.
It may seem absurd at the moment, but I see the benefits in the long run.

As to the 'another thing':
Since this project haven't convinced many people yet, I've already wrote a few package.yaml's for some of the libraries. If anybody's interested - just let me know.

I'm currently working on creating list of compatible repositories and another list of custom-made package.yaml's for other libraries.
I hope people get involved and want to support this idea, by placing feature requests, reporting bugs and new ideas.

As for the python:
I used it "for now". I had an idea and wanted to know if I should follow it or just let it go.
At first I wanted to use pure Lua, but Lua has limited file support. So I needed something quickly and python was the best option for me, mainly because I had it already set up on my machine.

I may have another idea on how to get it to work in pure Lua, but I need to do more research.
Another option is to write an executable in C++, but here I also need to look deeper into the subject.


Also a side note just for you:
I didn't want to offend anyone, but you may be right about language difference. I'm Polish, so it could be my upbringing or my mentality.
wlf2789
Prole
Posts: 7
Joined: Wed Sep 16, 2015 12:07 am
Contact:

Re: Stanley - Git-based package manager for Lua

Post by wlf2789 »

zorg wrote: Mon Mar 30, 2020 3:46 pm Oh, i also like the fact that i need to have python3 bloat my system as well, when i want to develop a lua thing, but that may very well be just me. :o:
wlf2789 wrote: Tue Mar 31, 2020 7:34 am As for the python:
I used it "for now". I had an idea and wanted to know if I should follow it or just let it go.
At first I wanted to use pure Lua, but Lua has limited file support. So I needed something quickly and python was the best option for me, mainly because I had it already set up on my machine.

I may have another idea on how to get it to work in pure Lua, but I need to do more research.
Another option is to write an executable in C++, but here I also need to look deeper into the subject.

I did some research today and the good thing is that I'm currently trying to rewrite it to be pure Lua.
But I have some troubles making it self-sufficient lua script, since there's no built-in option to parse YAML files. I'm thinking about writing simple function to parse only necessary info from 'package.yaml' files.
alphabetr
Prole
Posts: 6
Joined: Fri Jun 08, 2018 8:40 pm

Re: Stanley - Git-based package manager for Lua

Post by alphabetr »

Hi there,

What would you say are the major differences between your approach and just
using LuaRocks? As far as I can tell there isn't anything stopping you from writing
a LuaRocks rockspec for libraries that don't already have them, but I guess you'd then
need to host your own backend for dependency resolution etc?
wlf2789
Prole
Posts: 7
Joined: Wed Sep 16, 2015 12:07 am
Contact:

Re: Stanley - Git-based package manager for Lua

Post by wlf2789 »

alphabetr wrote: Fri Apr 10, 2020 5:41 pm Hi there,

What would you say are the major differences between your approach and just
using LuaRocks? As far as I can tell there isn't anything stopping you from writing
a LuaRocks rockspec for libraries that don't already have them, but I guess you'd then
need to host your own backend for dependency resolution etc?
Hi :)

The major difference is that I focus on using git for downloading source code and store it per-project.
It's especially nice if you're working on multiple libraries simultaneously and need to try different versions and switch between them quickly.
You don't even have to upload any of your code anywhere if you don't want to and still have it added to 'autoload.lua' file.

And you're right, I could've used LuaRocks, but as you noticed, I would need to make my own backend for dependency resolution and generating autoload file, so I decided to just use git since it's the fastest and the most popular way to share and download code.
wlf2789
Prole
Posts: 7
Joined: Wed Sep 16, 2015 12:07 am
Contact:

Re: Stanley - Git-based package manager for Lua

Post by wlf2789 »

Hi everybody :)

I haven't been here for a while, but I have some good news :)
I've finally released lua-only version, so please go check it out.

https://stanley-lua.github.io/
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest