Skip to content

Scripting

Daniel Hazelbaker edited this page Aug 4, 2018 · 7 revisions

Scripting

You can now design scripts, in JavaScript, that let you automate tasks in RockDevBooster. More documentation is coming, but a good example is below. This script does the following:

  1. Ask the user what Template to use for the process (for example, a beta version of Rock).
  2. Deploys the template as the ScriptTest instance.
  3. Builds and installs 2 plugins
  4. Starts the instance
  5. Warms it up (i.e. loads a page in the background to get the RockWeb built and initialized.
  6. Runs a SQL query against the database to display the names of every person in the database.
  7. Tell the user they can now go to the instance and perform testing.
var verbose = false;

function GetInstance()
{
  // ITEM 1
  var template = Template.Prompt('Select a Template to build from');
  if (template == null) {
    Abort('Cancelled by user');
  }

  if (Instance.Exists('ScriptTest')) {
    Instance.Delete('ScriptTest');
  }

  // ITEM 2
  Log('Deploying ' + template.Name + ' as ScriptTest');
  var instance = template.Deploy('ScriptTest', function (message) {
    LogProgress(message);
  });
  Log(' Done');

  return instance;
}

function InstallPlugin(instance, plugin)
{
  var pluginBase = 'C:\\Users\\Daniel Hazelbaker\\Desktop\\Rockit\\';
  var pluginPath = pluginBase + plugin + '\\rockplugin.json';

  Log('Installing plugin ' + plugin);
  instance.InstallPlugin(pluginPath, verbose);
}

// ITEM 1 AND 2
var instance = GetInstance();

// ITEM 3
InstallPlugin(instance, 'com.blueboxmoon.WatchdogMonitor');
InstallPlugin(instance, 'com.blueboxmoon.ProjectManagement');

// ITEM 4
Log('Starting IIS');
instance.Start();

// ITEM 4
Log('Warming up IIS');
instance.Warmup();

// ITEM 6
var data = instance.ExecuteSql('SELECT * FROM [Person]');
Log('Got ' + data.length + ' people');
for (var i = 0; i < data.length; i++) {
  Log('Name: ' + data[i].FirstName + ' ' + data[i].LastName);
}

// ITEM 7
Log('------------');
Log('Instance ready. You are now free to test.');
Clone this wiki locally