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
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!
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"
}
}
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.ejs
console.log('<%- greeting %> <%- person %>');
pkg/package.json
{
"lucy_def": "hello-world",
"package_name": "js",
"files": [{
"from": "hello.ejs",
"to": "hello.js",
"method": "render"
}]
}
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.ejs
```java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("<%- greeting %> <%- person %>");
}
}
```
package.json
{
"lucy_def": "hello-world",
"package_name": "java",
"files": [{
"from": "hello.ejs",
"to": "HelloWorld.java",
"method": "render"
}]
}
Join the beta if you're intersted in giving it a shot!