README
# Radiate [![Build Status](https://img.shields.io/travis/stevelacy/radiate.svg?style=flat-square)](https://travis-ci.org/stevelacy/radiate) [![NPM version](https://img.shields.io/npm/v/radiate.svg?style=flat-square)](http://badge.fury.io/js/radiate)
development task runner
Run devop tasks, deploy code, and run commands on local and remote machines.
Usage
Install
npm install --global radiate
Use the command radiate
to run the tasks in your radiate.js
file.
file radiate.js
A radiate file exports a main function which takes one argument, the radiate instance.
'use strict';
module.exports = function(r) {
// Set config values
// String, value
r.set('env', 'development');
// => r.config.env == 'development'
// String, true
r.set('devops');
// => r.config.devops == true
// String, Object
r.set('development-server', {
host: '127.0.0.1',
user: 'root',
source: ['./*'],
destination: '/var/www/app',
pass: 'test',
flags: 'avz',
});
// Execute a shell command on the local machine with options
r.exec('ls', ['-al']);
// Execute pass through function
r.exec(function() {
// Any functions in a task
// Ex:
fs.mkdirSync('test');
});
// deploy (push) code to a remote server
// You must set the config for the server prior to the `deploy` command
// this will use the config set in `r.set('<server name>', {})`
// Ex: `r.set('development-server', {host: '127.0.0.1'})`
r.deploy('development-server');
// Run commands on the remote server
// Also requires the config set in `r.set('<server name>', {})`
r.remote('development-server', 'ls -al /tmp', function() {
// do stuff
});
};
CLI
Default task:
$ radiate
Radiate will run the main exported function by default
module.exports = function(r) {
// r.exec ...
}
Individual tasks:
$ radiate deploy
Radiate will run any task names which are exported
module.exports = {
build: function(r) {
// r.exec('build-assets', 'gulp');
},
deploy: function(r) {
// r.deploy('production');
}
}
|| Object)
set(String, StringThis also sets the server config for the commands deploy
and remote
Set a string to true
r.set('name');
// => r.config.name == true
Set a string to a value
r.set('name', 'value');
// => r.config.name == 'value'
Set a string to an object
r.set('name', {key: 'value'});
// => r.config.name == {key: 'value'}
deploy
or remote
tasks:
Setting servers for rsync is used to transfer the files. simple-ssh is used for the SSH sessions.
Example with Custom ssh keys/locations.
The param shell
allows you to add pure SSH Rsync commands as rsync(1) lists under option --rsh
or -e
r.set('development-server', {
host: '127.0.0.1',
user: 'root',
key: fs.readFileSync('/home/root/.ssh/id_rsa'),
source: ['./*'],
destination: '/tmp/',
shell: 'ssh -i /home/root/.ssh/id_rsa -oIdentitiesOnly=yes -oStrictHostKeyChecking=no',
flags: 'avz',
});
Refer to their docs for more complex connection settings.
, Function)
exec(String, ArrayExecute a shell command on the process machine (local)
r.exec('ls', ['-al'], function () {
});
, Function)
deploy(String, ObjectDeploy to the specified server via config This uses the preset server config from #set
r.deploy('development-server', function(r) {
})
)
remote(String, Object || String, FunctionExecute a shell command on the remote machine as defined by the server name in the config.
Second param as String(
r.remote('development-server', 'ls -al', function(r) {
// do stuff
});
Second param as Object({cmd:
r.remote('development-server', {cmd: 'ls -al'}, function(r) {
// do stuff
});