Example #1
0
  describe('('+ planObject.description +')', function () {
    this.timeout(600 * 1000); // 10 minutes

    before(function () {
      planner.compileOptions(plan, options);
      planner.verifyOptions(plan, options);
    });

    lib.util.eachTask(plan, function (task, phase, taskName) {
      it(getPackageName(phase.name, taskName) + '#beforeInstall', function () {
        task.beforeInstall(options);
      });
    });

    lib.util.eachTask(plan, function (task, phase, taskName) {
      var pkgName = getPackageName(phase.name, taskName);
      var spec = require(pkgName + '/spec');
      if (_.isFunction(spec.beforeExecute)) {
        spec.beforeExecute(options);
      }
    });

    lib.util.eachTask(plan, function (task, phase, taskName) {
      var pkgName = getPackageName(phase.name, taskName);
      var spec = require(pkgName + '/spec');
      var phaseOptions = phase.options || { };

      describe(pkgName, function () {
        if (phaseOptions.execute === false) return;

        it('#beforeTask, #executeTask, #afterTask', function () {
          task.beforeTask(options);
          task.executeTask(options);
          task.afterTask(options);
        });

        if (_.isFunction(spec.afterTask)) {
          spec.afterTask(options);
        }
      });
    });

    lib.util.eachTask(plan, function (task, phase, taskName) {
      var pkgName = getPackageName(phase.name, taskName);
      var spec = require(pkgName + '/spec');

      it(pkgName + '#afterInstall', function () {
        task.afterInstall(options);
        if (_.isFunction(spec.afterExecute)) {
          spec.afterExecute(options);
        }
      });
    });

  });
Example #2
0
  describe('after execute', function () {

    lib.util.eachTask(plan, function (task, phase, taskName) {
      it(getPackageName(phase.name, taskName) + '#afterInstall', function () {
        task.afterInstall(options);
      });
    });

    lib.util.eachTask(plan, function (task, phase, taskName) {
      var pkgName = getPackageName(phase.name, taskName);
      var spec = require(pkgName + '/spec');
      if (_.isFunction(spec.afterExecute)) {
        spec.afterExecute(options);
      }
    });
  });
Example #3
0
function executePlan (plan, options) {
  options.plan = plan;

  if (!_.isString(options.planName)) {
    throw new Error('planName is required');
  }

  // beforeInstall
  log.info('xtuple', 'Pre-flight checks...');
  lib.util.eachTask(plan, function (task, phase, taskName) {
    log.verbose(prefix(phase.name, taskName), 'beforeInstall');
    task.beforeInstall(options);
  }, options);

  if (/^uninstall/.test(options.planName)) {
    return uninstall(options);
  }

  // execute plan tasks
  lib.util.eachTask(plan, function (task, phase, taskName) {
    var phaseOptions = phase.options || { };

    if (phaseOptions.execute !== false) {
      log.info(prefix(phase.name, taskName), 'Running...');
      task.beforeTask(options);
      task.executeTask(options);
      task.afterTask(options);
    }

  }, options);

  log.info('xtuple', 'Finishing...');
  lib.util.eachTask(plan, function (task, phase, taskName) {
    log.verbose(prefix(phase.name, taskName), 'afterInstall');
    task.afterInstall(options);
  }, options);
}
Example #4
0
  compileOptions: function (plan, options) {
    lib.util.eachTask(plan, function (task, phase, taskName) {
      options[phase.name] || (options[phase.name] = { });
      options[phase.name][taskName] || (options[phase.name][taskName] = { });

      phase.options || (phase.options = { });

      // load in default options specified in planfile
      if (_.isObject(phase.options)) {
        _.defaults(options[phase.name], phase.options);
      }

      // load in default options specified in task modules
      _.each(task.options, function (option, optionName) {
        if (_.isUndefined(options[phase.name][optionName])) {
          options[phase.name][optionName] = option.value;
        }
      });
    });
  },
Example #5
0
  describe('execute', function () {
    
    lib.util.eachTask(plan, function (task, phase, taskName) {
      var pkgName = getPackageName(phase.name, taskName);
      var spec = require(pkgName + '/spec');

      describe(pkgName, function () {

        it('#beforeTask, #executeTask, #afterTask', function () {
          task.beforeTask(options);
          task.executeTask(options);
          task.afterTask(options);
        });

        if (_.isFunction(spec.afterTask)) {
          spec.afterTask(options);
        }
      });
    });
  });
Example #6
0
 verifyOptions: function (plan, options) {
   log.verbose('verifyOptions');
   if (_.isEmpty(options.type)) {
     throw new TypeError('<type> is a required field');
   }
   lib.util.eachTask(plan, function (task, phase, taskName) {
     _.each(task.options, function (option, key) {
       log.verbose('verifyOptions', 'verifying', key);
       if (_.isFunction(option.validate) && phase.options.validate !== false) {
         // this will throw an exception if invalid
         log.verbose(prefix(phase.name, taskName), 'Validating Option: '+ key);
         try {
           options[phase.name][key] = option.validate(options[phase.name][key], options);
         }
         catch (e) {
           log.error('verifyOptions', e.message);
           log.error('verifyOptions', e.stack.split('\n'));
           process.exit(1);
         }
       }
     });
   });
 },