lib/deployer.js
function(origin, target, plan, mode, out, completeCb) {
    var c;
    var container;
    var containerDef;
    out.initProgress(plan.length, '--> deploying plan...');
    var currProgress = 0;
    var prnt;

    function tick(command, c) {
      currProgress += 1;
      out.progress(command + ' ' + c.id + ' ' + (c.type || ''));
    }

    logger.info('deploying plan');
    async.eachSeries(plan, function(step, cb) {
      c = target.topology.containers[step.id] || origin.topology.containers[step.id];
      container = _.cloneDeep(c);
      prnt = target.topology.containers[step.parent] || origin.topology.containers[step.parent];
      containerDef = _.find(target.containerDefinitions, function(cdef) {
        return cdef.id === container.containerDefinitionId;
      });
      if (!containerDef) {
        containerDef = _.find(origin.containerDefinitions, function(cdef) {
          return cdef.id === container.containerDefinitionId;
        });
      }
      if (container.specific && origin.topology.containers[step.id] && origin.topology.containers[step.id].specific) {
        container.specific = merge(container.specific, origin.topology.containers[step.id].specific);
      }
      logger.info('calling: ' + step.cmd);

      // matchup containers to type and apply matching function remove executor
      var err = 'no matching container available for type';
      if (containerDef && containerDef.type) {
        _containers.getHandler(target, containerDef.type, function(err, impl) {
          if (err) { return cb(err); }
          if (!impl) { logger.error(err); return cb(new Error(err)); }
          tick(step.cmd, container);
          impl[step.cmd](mode, prnt.specific, target, containerDef, container, out, function(err, newTarget, replace){
            if (newTarget) {
              target = newTarget;
              if (replace) {
                _.each(replace, function(repl) {
                  plan = sd.replaceId(repl.oldId, repl.newId, plan);
                });
              }
            }
            cb(err);
          });
        });
      }
      else {
        cb();
      }
    }, function(err) {
      completeCb(err, target);
    });
  }
function(origin, target, plan, mode, out, completeCb) {
    var c;
    var container;
    var containerDef;
    out.initProgress(plan.length, '--> deploying plan...');
    var currProgress = 0;
    var prnt;

    function tick(command, c) {
      currProgress += 1;
      out.progress(command + ' ' + c.id + ' ' + (c.type || ''));
    }

    logger.info('deploying plan');
    async.eachSeries(plan, function(step, cb) {
      c = target.topology.containers[step.id] || origin.topology.containers[step.id];
      container = _.cloneDeep(c);
      prnt = target.topology.containers[step.parent] || origin.topology.containers[step.parent];
      containerDef = _.find(target.containerDefinitions, function(cdef) {
        return cdef.id === container.containerDefinitionId;
      });
      if (!containerDef) {
        containerDef = _.find(origin.containerDefinitions, function(cdef) {
          return cdef.id === container.containerDefinitionId;
        });
      }
      if (container.specific && origin.topology.containers[step.id] && origin.topology.containers[step.id].specific) {
        container.specific = merge(container.specific, origin.topology.containers[step.id].specific);
      }
      logger.info('calling: ' + step.cmd);

      // matchup containers to type and apply matching function remove executor
      var err = 'no matching container available for type';
      if (containerDef && containerDef.type) {
        _containers.getHandler(target, containerDef.type, function(err, impl) {
          if (err) { return cb(err); }
          if (!impl) { logger.error(err); return cb(new Error(err)); }
          tick(step.cmd, container);
          impl[step.cmd](mode, prnt.specific, target, containerDef, container, out, function(err, newTarget, replace){
            if (newTarget) {
              target = newTarget;
              if (replace) {
                _.each(replace, function(repl) {
                  plan = sd.replaceId(repl.oldId, repl.newId, plan);
                });
              }
            }
            cb(err);
          });
        });
      }
      else {
        cb();
      }
    }, function(err) {
      completeCb(err, target);
    });
  }
function ( origin , target , plan , mode , out , completeCb ) { var c ; var container ; var containerDef ; out . initProgress ( plan . length , '--> deploying plan...' ) ; var currProgress = 0 ; var prnt ; function tick ( command , c ) { currProgress += 1 ; out . progress ( command + ' ' + c . id + ' ' + ( c . type || '' ) ) ; } logger . info ( 'deploying plan' ) ; async . eachSeries ( plan , function ( step , cb ) { c = target . topology . containers [ step . id ] || origin . topology . containers [ step . id ] ; container = _ . cloneDeep ( c ) ; prnt = target . topology . containers [ step . parent ] || origin . topology . containers [ step . parent ] ; containerDef = _ . find ( target . containerDefinitions , function ( cdef ) { return cdef . id === container . containerDefinitionId ; } ) ; if ( ! containerDef ) { containerDef = _ . find ( origin . containerDefinitions , function ( cdef ) { return cdef . id === container . containerDefinitionId ; } ) ; } if ( container . specific && origin . topology . containers [ step . id ] && origin . topology . containers [ step . id ] . specific ) { container . specific = merge ( container . specific , origin . topology . containers [ step . id ] . specific ) ; } logger . info ( 'calling: ' + step . cmd ) ; // matchup containers to type and apply matching function remove executor var err = 'no matching container available for type' ; if ( containerDef && containerDef . type ) { _containers . getHandler ( target , containerDef . type , function ( err , impl ) { if ( err ) { return cb ( err ) ; } if ( ! impl ) { logger . error ( err ) ; return cb ( new Error ( err ) ) ; } tick ( step . cmd , container ) ; impl [ step . cmd ] ( mode , prnt . specific , target , containerDef , container , out , function ( err , newTarget , replace ) { if ( newTarget ) { target = newTarget ; if ( replace ) { _ . each ( replace , function ( repl ) { plan = sd . replaceId ( repl . oldId , repl . newId , plan ) ; } ) ; } } cb ( err ) ; } ) ; } ) ; } else { cb ( ) ; } } , function ( err ) { completeCb ( err , target ) ; } ) ; }
Deploy a plan
See https://github.com/nearform/nscale-planner for a plan example.

origin - origin system definition
target - target system definition
plan   - execution plan
mode   - preview or live
out    - output handles
completeCb - completion callback
Deploy a plan See https : // github . com / nearform / nscale - planner for a plan example .