$ sudo npm install -g pollinate
Think of a tree of files as a Flower
and a source data as Pollen
; combined
together they create a fertilized project. Pollinate will allow you to template
a set of files and store them on GitHub. When you decide to use them later you
can pollinate them using an object of data.
All templates are parsed with Nunjucks
The Flower
is a GitHub repository which holds all of the files. Any file can
can be passed through a template engine using the supplied data. Some files like
the original README may need to go, and maybe a new templated README will need to
take its place. The Flower
also supplies its own default data object.
The Pollen
is pretty much just a vessel to get new data to the Flower
. Much
like how pollen works in nature. It can be supplied as an HTTP JSON endpoint, as
a local file, or directly as a set of arguments.
Consider the data to be more like the DNA of the operation. Both sides can
supply it, but the data from the Pollen
takes precedence when merging the
objects. The data supplies a list of files to act upon with the template engine
along with the data to inject. The data can also supply file operations to move
or delete files during the process.
$ pollinate codingcoop/test-flower test.json
or
$ pollinate codingcoop/test-flower '{"name":"codingcoop","context":{"box_name":"trusty64","box_url":"http://files.vagrantup.com/trusty64.box"}}'
.
├── PROJECT-README
├── README.md
├── Vagrantfile
└── flower.json
{
"name": "newproject",
"context": {
"box_name": "precise64",
"box_url": "http://files.vagrantup.com/precise64.box"
},
"operations": {
"discard": [
"README.md",
"LICENSE"
],
"parse": [
"PROJECT-README",
"Vagrantfile"
],
"move": [
{ "PROJECT-README": "README.md" }
]
}
}
# {{ name }}
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "{{ box_name }}"
config.vm.box_url = "{{ box_url }}"
end
{
"name": "codingcoop",
"context": {
"box_name": "trusty64",
"box_url": "http://files.vagrantup.com/trusty64.box"
}
}
{
"name": "codingcoop",
"context": {
"box_name": "trusty64",
"box_url": "http://files.vagrantup.com/trusty64.box"
},
"operations": {
"discard": [
"README.md",
"LICENSE"
],
"parse": [
"Vagrantfile",
"PROJECT-README"
],
move: [
{ "PROJECT-README": "README.md" }
]
}
}
.
└── codingcoop
├── README.md
└── Vagrantfile
# codingcoop
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "trusty64"
config.vm.box_url = "http://files.vagrantup.com/trusty64.box"
end
(Don't forget to jump into the directory)
$ cd codingcoop