-
Notifications
You must be signed in to change notification settings - Fork 5
Scripting
Daniel Hazelbaker edited this page Aug 13, 2018
·
7 revisions
You can now design scripts, in JavaScript, that let you automate tasks in RockDevBooster.
I still need to write up real documentation on the features available, but here is a quick list:
-
Template
- Template Class reference. -
Instance
- Instance Class reference. -
Log(message)
- Logs a line of text to the RockDevBooster window. -
LogProgress(message)
- Logs a line of text without adding a new line (think "1%...", then replaced with "2%...", and so on). -
Abort(message)
- Aborts the script and displays the given message. -
Beep()
- Plays the default system beep sound.
-
All()
- Get the names of all installed templates. -
Exists(name)
- Check if the named template exists. -
Prompt(title)
- Prompt the user to select a template (returns a Template instance).
-
Deploy(instanceName, progressCallback)
- Deploys a template as a new instance.
-
All()
- Get the names of all installed instances. -
Exists(name)
- Check if the named instance exists. -
Prompt(title)
- Prompt the user to select a instance (returns an Instance instance). -
Delete(name)
- Delete the named instance.
-
Start()
- Starts the IIS Express process for the instance. -
Stop()
- Stops the IIS Express process. -
InstallPlugin(pluginSpecFile, [verbose])
- Builds a rockplugin.json based plugin and installs it into the instance. -
Warmup()
- Requests the / page of the site to make sure Rock is warmed up. -
CopyFile(src, dest, [verbose])
- Copies a file or directory into the RockWeb directory of the instance. -
DeleteFile(path, [verbose])
- Deletes the file or directory from the RockWeb directory of the instance. -
FileExists(path)
- Checks if the file exists inside the RockWeb directory. -
DirectoryExists(path)
- Checks if the directory exists inside the RockWeb directory. -
ExecuteSqlStatement(sql)
- Executes a non-select statement (such as DELETE). -
ExecuteSqlScalar(sql)
- Executes a select statement that returns a single row single value. -
ExecuteSql(sql)
- Executes a select statement that returns multiple rows and/or columns. -
HasRecentMigrationExceptions([showExceptions])
- Checks if any migration exceptions have been logged since the script started and optionally logs those errors to the console.
A quick example is below. This script does the following:
- Ask the user what Template to use for the process (for example, a beta version of Rock).
- Deploys the template as the
ScriptTest
instance. - Builds and installs 2 plugins
- Starts the instance
- Warms it up (i.e. loads a page in the background to get the RockWeb built and initialized.
- Runs a SQL query against the database to display the names of every person in the database.
- 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.');