This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
H4X0RZ's profile picture

Glue - Dependency management made easy

Started by H4X0RZ, 21 August 2016 - 03:15 PM
H4X0RZ #1
Posted 21 August 2016 - 05:15 PM



Installation
  1. Install Packman
  2. run packman fetch
  3. run packman install glue
  4. ???
  5. Profit
This will also download h4x0rz/json, because it depends on this library.

This is Glue
Glue is a simple tool which allows you to easily manage your dependencies. It is inspired my tools like bundler and composer. All the dependencies are specified in the GlueFile found in the root of your project. It features a custom DSL and an online storage for Drops.

Why I chose the name
That's simple. APIs/Utilities/Dependencies (whatever you want to call the stuff your code depends on) are the same as the glue you use when building real stuff. They make everything stick together and work. That's why one dependency is called a drop. For small projects, you only need a small amount of glue, but the bigger your project becomes, the more glue you need and the more drops (of glue) you add.

Why you should use Glue
  • It's easier for you to sort your dependencies
  • Once you defined your GlueFile, Glue will take care of downloading everything for you
  • You can ship your code without the dependencies and let Glue handle installing them. No need for complicated installers anymore
  • The code will always have the right version of your dependencies
  • It's awesome. Just use it.
Tutorial
If you haven't installed it yet, go back to the top of this page and do it. Unless you just want to see how it works ;D

you can easily create a new Glue project by either calling
glue init
or
glue init <folder>
This will initialize either your current folder, or the one you specified, as a Glue project.

The folder will contain some new things now. The most interesting one is the GlueFile.
the DSL is really simple, so I'll just copy the docs you can find at the top of every GlueFile here:

--
--Either depend on the latest version
--depend "json"
--
--Or depend on a specific version
--depend "json" version "1"
--
--You can also define how the dependency should be loaded
--Valid methods are: dofile and os.loadAPI
--depend "json" method "dofile"
--
--dofile also has support for the "namepsace" method
--depend "json" method "dofile" namespace "JSON"
--This way you can decide where the loaded dependency should be located
--
--Of course you can use all of these in a combination too:
--depend "json" version "1" method "dofile" namespace "JSON_IS_AWESOME"
--
I hope this explains how GlueFiles work.

After you defined all your dependencies it's time to install them. Just run
glue install
and it will download all the dependencies and put them into a new hidden folder, .glue.

Then there's only one thing left, actually loading the files. Just execute ".glue/autoload.lua" somewhere in your script, and all the dependencies will be available!

Uploading a Drop
This is a piece of cake!
Just head over to this page, register/login and press the "upload" button; Fill out all the fields and you're done!

Have a nice day,
~H4X0RZ
Edited on 28 August 2016 - 12:26 AM
ebernerd #2
Posted 21 August 2016 - 06:17 PM
Just so you know, you misspelled "dependency" in your title. ;)/>

Other than that, this looks pretty good.
H4X0RZ #3
Posted 21 August 2016 - 07:48 PM
Just so you know, you misspelled "dependency" in your title. ;)/>

Other than that, this looks pretty good.
Thanks for spotting the typo. Fixed! :)/>

BTW, there is one drop already available. It's "json" (the one I used for the examples).
Admicos #4
Posted 21 August 2016 - 08:56 PM
Just so you know, you misspelled "dependency" in your title. ;)/>

Other than that, this looks pretty good.
Thanks for spotting the typo. Fixed! :)/>

BTW, there is one drop already available. It's "json" (the one I used for the examples).
When i'm trying to update the packman packages, i get a error "Could not resolve dependency on thefreaklord/json in package h4x0rz/glue". Can you fix your repo file?
H4X0RZ #5
Posted 21 August 2016 - 09:45 PM
Just so you know, you misspelled "dependency" in your title. ;)/>/>

Other than that, this looks pretty good.
Thanks for spotting the typo. Fixed! :)/>/>

BTW, there is one drop already available. It's "json" (the one I used for the examples).
When i'm trying to update the packman packages, i get a error "Could not resolve dependency on thefreaklord/json in package h4x0rz/glue". Can you fix your repo file?

Just realized that I still had that in there. fixing it now. Done.
Edited on 21 August 2016 - 08:05 PM
Lupus590 #6
Posted 22 August 2016 - 12:26 PM
After explaining GlueFiles you call them GemFiles, that looks like its a typo.
H4X0RZ #7
Posted 22 August 2016 - 03:56 PM
After explaining GlueFiles you call them GemFiles, that looks like its a typo.

Oh, damn. How could I not see this. Sorry! That's because I got the idea for the GlueFiles from bundler, which uses Gemfiles to organize gems in a Ruby project. (^-^; )
Edited on 22 August 2016 - 03:42 PM
Admicos #8
Posted 27 August 2016 - 06:31 PM
When i'm trying to update the packman packages, i get a error "Could not resolve dependency on thefreaklord/json in package h4x0rz/glue". Can you fix your repo file?
Sorry, but this is happening again. Can you fix it?
Edited on 27 August 2016 - 04:32 PM
H4X0RZ #9
Posted 28 August 2016 - 02:15 AM
When i'm trying to update the packman packages, i get a error "Could not resolve dependency on thefreaklord/json in package h4x0rz/glue". Can you fix your repo file?
Sorry, but this is happening again. Can you fix it?
Fixed.

Also, I redid the web client. Now you can register/login, search/browse and upload drops.
It's impossible to "edit" drops now. If you want to change the code, you have to push another version. This will enforce version-safety for everyone using Glue as dependency manager. I hope this little inconvenience won't stop any dev from using Glue to share their code.