Lucy
Lucy is a tool for sharing, coordinating, and automating code in any language. Lucy works by feeding JSON into code templates, producing customized code that compiles and runs.
Lucy is just getting started, but you can keep up with the latest news and learn about what lucy can do here:
http://lucybot.github.io/blog/
Want to get an early peek at everything lucy can do? Join the beta!
Installation
You'll need nodejs to run lucy:
https://github.com/joyent/node/wiki/installing-node.js-via-package-manager
sudo npm install -g lucy
lucy adduser
Usage
Build an existing package
lucy build definition:package config.json
Push a new definition
Note: define is currently only open to beta testers. Join the beta for access
lucy define definition.json
Add a package to an existing definition
Note: publish is currently only open to beta testers. Join the beta for access
lucy publish /path/to/directory/containing/package.json
About
There are two main components to a lucy module:
- DEFINITION - this is JSON that describes what kind of code is being generated, and provides a sample configuration.
- PACKAGE - this is a set of code templates, scripts, and files that will be used to generate code. There can be multiple packages per definition.
Most users will simply run lucy build
to generate code from an existing lucy package. However, you can also create your own definitions and packages to share with others. Let's walk through a "hello world" example.
Note that while we're in beta, the define
and publish
commands won't work unless you're signed up. Feel free to jump ahead to build
though!
Quickstart
To download all the files described in this tutorial, enter a new directory and run
lucy build hello-world-starter '{"username": "SOME_UNIQUE_ID"}'
choosing a unique id that won't collide with other hello-world-* definitions.
you can then run
lucy define def.json
lucy publish pkg
lucy build hello-world-YOUR_UNIQUE_ID:js config.json
lucy publish javapkg
lucy build hello-world-YOUR_UNIQUE_ID:java config.json
The Definition
We start with a definition:
def.json
{
"name": "hello-world",
"description": "A hello world example for lucy",
"sample_input": {
"greeting": "Hello",
"person": "world"
}
}
(you'll need to replace "hello-world" with something unique)
and run:
lucy define def.json
which pushes the definition to lucy's servers.
The Package
Now we create a package by starting a new directory 'pkg'
pkg/hello.js
console.log('<%- greeting %> <%- person %>');
pkg/package.json
{
"lucy_def": "hello-world",
"package_name": "js",
"files": [{
"from": "hello.js"
}]
}
and run
lucy publish pkg
which will zip up the directory and upload the resulting tarball.
Build!
Now anyone can create a config.json like
config.json
{
"greeting": "Yo",
"person": "lucy"
}
and run
lucy build hello-world:js config.json
which will generate this file in the working directory:
hello.js
console.log("Yo lucy");
### Extend! What's more, you (or anyone else) can add other packages to the hello-world definition, for example:
Hello.java ```java public class Hello { public static void main(String[] args) { System.out.println("<%- greeting %> <%- person %>"); } } ```
package.json
{
"lucy_def": "hello-world",
"package_name": "java",
"files": [{
"from": "Hello.java"
}]
}
Join the beta if you're intersted in giving it a shot!