pollinate 0 travis-ci npm

Generate a new project directly from Git(Hub) using a simple schema.

Pollinate

Generate a new project directly from Git(Hub) using a simple schema.

stability npm version Build Status Coverage Status Dependency Status

What?

It is a command that takes a templated tree of files and generates them for new projects using data defined by a simple schema. The data can define an output name, files to discard, files to parse with the data, and files to move or rename. The template can supply the default data, and that data can be extended for each project. You can throw in any other data you'd like to be passed to the template context as well.

All templates are parsed with Nunjucks aka Jinja and Twig.

Why?

When starting new projects the quickest way is often to just copy the last project and fiddle with it until it works. This can introduce many unwanted issues, like having one client's name appear in place of the other's. This project's goal is to offer an elegant and efficient way of working with a base set of files that can be understood by looking at a single example.

Install

$ npm install -g pollinate

An example

$ pollinate howardroark/webapp --name newproject --container alpine --description="A thing that does something."

Skip to more examples...

The GitHub sourced template
.
├── PROJECT-README
├── README.md
├── Dockerfile
├── project-name
└── template.json
template.json (optional)
{
  // Core schema
  "name": "webapp",
  "parse": [
    "PROJECT-README",
    "Dockerfile"
  ],
  "discard": [
    "README.md",
    "template.json"
  ],
  "move": [
    { "PROJECT-README": "README.md" },
    { "project-name": "{{ name }}.txt" }
  ],
  // Custom defaults
  "container": "debian",
  "description": "Lorem ipsum dolor sit amet, consectetur adipiscing elit."
}

You can omit any or all of discard, parse and move.

PROJECT-README
# {{ name }}

{{ description }}
Dockerfile
FROM {{ container }}
The project data
{
  "name": "newproject",
  "container": "alpine",
  "description": "A thing that does something."
}
The data after extending and parsing
{
  "name": "newproject",
  "parse": [
    "Dockerfile",
    "PROJECT-README"
  ],
  "discard": [
    "README.md",
    "template.json"
  ],
  "move": [
    { "PROJECT-README": "README.md" },
    { "project-name": "newproject.txt" }
  ],
  "container": "alpine",
  "description": "A thing that does something."
}
The result
.
└── newproject
   ├── README.md
   ├── newproject.txt
   └── Dockerfile
README.md
# newproject

A thing that does something.
Dockerfile
FROM alpine

More examples

You can specify template files as a local directory (.git will be removed)

$ pollinate ./template --name newproject --container ubuntu

You can use any Git url (.git will be removed)

$ pollinate https://github.com/howardroark/webapp.git --name newproject --container ubuntu

You can pass project data as a file

$ pollinate howardroark/webapp data.json

You can pass project data as a JSON string

$ pollinate howardroark/webapp '{"name":"newproject","container":"alpine","description":"A thing that does a thing."}'

You can pass project data as a JSON endpoint

$ pollinate howardroark/webapp https://example.com/json/data

You can supply a target directory (will create directories that do not exist).

$ pollinate howardroark/webapp target

or

$ pollinate howardroark/webapp /target/directory data.json

You can generate from the default data in the template

$ pollinate howardroark/webapp

You can override data as CLI options

$ pollinate howardroark/webapp data.json --name=alternate --container=ubuntu

You can specify a command to run on completion

{
  "complete": "git init {{ name }}"
}

You can ask pollinate to parse all files by defaut

{
  "parse": "*"
}

You can supply user specific data each time with a ~/.pollen defaults file

{
  "api_key":"secret"
}

You can supply custom Nunjucks filter functions (files must be included within template)

{
  "filters": {
    "markdown": "filters/markdown.js"
  }
}
filters/markdown.js
var markdownParser = function() { ... }

module.exports = function(markdownText) {
  var html = markdownParser(markdownText)
  return '<div class="markdown">'+html+'</div>'
}

You can supply a questions object to prompt for data with Inquirer.js (file must be included in template)

{
  "questions":"inquirer-questions.js"
}
inquirer-questions.js
module.exports = [
  {
    type: 'input',
    name: 'name',
    message: 'Input a computer friendly name for your project.',
    default: 'newproject'
  },
  {
    type: 'input',
    name: 'description',
    message: 'Input a brief description of your project.',
    default: 'My new project!'
  }
]

Shout-outs

Thanks to Alim Maasoglu for the fantastic work on the logo!

Related Repositories

awesome-projects-boilerplates

awesome-projects-boilerplates

Boilerplates for mobile and web apps ...

bootstrap-dht

bootstrap-dht

DHT bootstrap server ...

plant-vs-animal-products

plant-vs-animal-products

A definitive comparison of plant versus animal products ...

bangalore-startups

bangalore-startups

Ever growing list of startups in Bangalore. ...

ct-honeybee

ct-honeybee

Lightweight program that pollinates STHs between Certificate Transparency logs a ...


Top Contributors

howardroark ben657

Dependencies

package version
async ^2.1.4
cli-argparse ^1.1.0
commander ^2.9.0
extend ^3.0.0
globby ^6.1.0
gunzip-maybe ^1.3.1
hjson ^2.3.1
is-directory ^0.3.1
mkdirp ^0.5.1
cpr ^2.0.2
mv ^2.1.1
node-dir ^0.1.11
nunjucks ^3.0.0
ospath ^1.2.2
request ^2.69.0
rimraf ^2.5.2
tar-fs ^1.9.0
uuid ^3.0.1
valid-url ^1.0.9
dev chai ^3.5.0
coveralls ^2.11.8
istanbul ^0.4.2
jslint ^0.10.3
mocha ^2.4.5

Releases

-   v1.15.0 zip tar
-   v1.14.2 zip tar
-   v1.14.1 zip tar
-   v1.14.0 zip tar
-   v1.13.2 zip tar
-   v1.13.1 zip tar
-   v1.13.0 zip tar
-   v1.12.3 zip tar
-   v1.12.2 zip tar
-   v1.12.1 zip tar
-   v1.12.0 zip tar
-   v1.11.0 zip tar
-   v1.10.0 zip tar
-   v1.9.0 zip tar
-   v1.8.1 zip tar
-   v1.8.0 zip tar
-   v1.7.1 zip tar
-   v1.7.0 zip tar
-   v1.6.0 zip tar
-   v1.5.5 zip tar
-   v1.5.4 zip tar
-   v1.5.3 zip tar
-   v1.5.2 zip tar
-   v1.5.1 zip tar
-   v1.5.0 zip tar
-   v1.4.1 zip tar
-   v1.4.0 zip tar
-   v1.3.0 zip tar
-   v1.2.4 zip tar
-   v1.2.3 zip tar