/packman

Code scaffolding tool by SecureNative

Primary LanguageGoMIT LicenseMIT

Packman

Project Scaffolding for Professionals

Motivation

At SecureNative, we push new micro-services on a daily basis and the job of creating new projects, wiring it up, importing our common libs, etc.. is a tedious job and should be automated :)
packman is a simple tool that allows you to generate boilerplate without sacrificing your freedom as a developer, no new DSL to learn, no weird config files to edit, only you and your favourite language decides the limits.

We are using packman intensively at SecureNative for the past 10 months, keeping our developers focused on the real problems instead of writing the same things again and again, we've developed wide range of packman templates from simple rest application, producer-worker application or even creating an entire project from a single protobuf file.

Prerequisites

How to get it

If you have golang installed just use:
go get -u github.com/securenative/packman

You can also use one of the pre-built binaries from our releases page

after that you can use packman to get templates, try it now:

packman unpack \
    https://github.com/securenative/packman-init \
    packmanExample \
    -author matan \
    -company SecureNative

API Reference

Render

While working on your template project you'll need to constantly render your template to check if it works.
The packman render command will take a local path to the template's folder and a list of custom flags and in return will create a new folder with the rendered template.

packman render <TEMPLATE_PATH> \
    -key-1 value-1 \ 
    -key-2 value-2 \
    ... \
    -key-n value-n

For example if I have a template called myProject and it requires the following flags: host, port running:

packman render myProject \
    -host 127.0.0.1 \ 
    -port 9909

will create a new folder called myProject-rendered with the rendered template.

Unpack

Unpack is the "wet" version of render, the only difference is that unpack will ask you where to get the template from (i.e which git repository to clone).

packman unpack <REMOTE_PATH> <LOCAL_PATH> \
    -key-1 value-1 \ 
    -key-2 value-2 \
    ... \
    -key-n value-n

Pack

Pack will just commit and push your changes to the remote git repository, if you prefer (and basically you should) you can manage it manually with your favourite git client.

packman pack <LOCAL_PATH> <REMOTE_PATH>

Auth

To get access to private repositories or to use the packman pack command you'll need to authenticate with git.

packman auth <USERNAME> <PASSWORD>

Change the default script engine

While the default script engine uses GO and as much as we love GO at SecureNative, packman was built as an un-opinionated tool so we don't impose any limit on your scripting capabilities.
You can use any language to write scripts, damn, you can even use bash scripts to generate your template as long as you respect the interface with packman.
packman scripts defines 2 standards that you must comply to:

  1. The script will be executed with 2 additional command-line arguments, the path to the flags.json file and the path to save the reply.json file.
  2. The script has to write its reply (as json) to the reply path (provided as a cli argument)

You can see its pretty simple requirements to fulfil, you can check this code to better understand it.

packman script "go run" # Will run go files
packman script "python" # will run python files
packman script "node"   # will run javascript files