tooltwist
Version:
Tooltwist Command Line Interface
158 lines (127 loc) • 4.15 kB
JavaScript
/**
* Plugin to run the ToolTwist Designer on a webdesign.
*/
var mkdirp = require('mkdirp'),
Config = null,
Log = null;
/**
* Set up the plugin
*/
exports.init = function(appDir) {
//console.log('plugins.designer.init()')
// Run requires, based on main app directory (i.e. not relative to the plugin)
Log = require(appDir + '/log');
Config = require(appDir + '/config');
Templates = require(appDir + '/templates');
}
/**
* Create a default config file for the Designer.
*/
exports.commandLineInit = function() {
//console.log('plugins.designer.commandLineInit()')
// Use the template to create the initial config file
var from = __dirname + '/templates/' + "designer-tooltwist.js"
Log.debug('from=' + from)
var data = {
MODE: 'designer'
};
var creatingExampleTemplate = false;
Templates.copy(from, Config.CONFIG_FILE, creatingExampleTemplate, data);
// Display a nice message.
Log.always();
Log.always('\tSpecification file \'' + Config.CONFIG_FILE + '\' has been created with a default');
Log.always('\tconfiguration that will run the ToolTwist Designer on the demo')
Log.always('\twebdesign project \'ttdemo\'.');
Log.always();
Log.always('\tModify this file to suit your needs, then run:');
Log.always();
Log.always('\t$ tooltwist designer')
Log.always();
// All done
process.exit(0)
}
exports.beforePhase1 = function() {
//console.log('plugins.designer.beforePhase1()')
var config = Config.getConfig();
// DESIGNER MODE
Config.REPO = config['designer'].repo;
//ZZZ check is set
Config.BRANCH = config['designer'].branch;
// ZZZ check works if undefined
Config.USE_PHASE2 = false;
}
/**
* This function is called as soon as PHASE1 detects that Tomcat is running.
*/
exports.tomcatRunning = function() {
//console.log('plugins.designer.tomcatRunning()')
// Display a nice message for Designer users.
//Log.log();
Log.log(' (Server can be stopped with Control-C)');
Log.log();
Log.log();
Log.log();
Log.log('\t\t THE SERVER IS NOW RUNNING.')
Log.log();
Log.log('\t\t http://localhost:' + Config.HTTP_PORT + '/ttsvr/login');
Log.log();
Log.log();
Log.log();
//Log.log(' Default log file is ' + Config.HIDDEN_DIR + '/tooltwist.log')
}
/**
* This function is called after generating the default build files from
* templates, but before starting Phase 2. Note that phase 2 occurs WITHIN
* phase 1, so afterPhase1() has not been called yet.
*/
exports.beforePhase2 = function() {
//console.log("plugins.designer.beforePhase2");
// Create Designer-specific config files
var templateDir = __dirname + '/templates';
var outputsDir = Config.HIDDEN_DIR + '/';
var creatingExamples = false;
Templates.copyTemplateDirectory(templateDir, 'designer', 'docker-production-', creatingExamples, outputsDir, Config.getConfig());
}
exports.afterPhase2 = function() {
//console.log("plugins.designer.afterPhase2");
// Create Dockerfile
//ZZZZ
}
exports.afterPhase1 = function(status) {
//console.log('plugins.designer.afterPhase1()')
/*
* Gradle Finished callback.
*/
Log.debug("GRADLE FINISHED (" + status + ")")
// Check that the Gradle operations completed.
if (status !== 0) {
// Display a message and bomb out.
Log.fatalError("Gradle finished with exit status " + status);
} else {
// Clean exit
console.log(' ')
console.log(' ### # # ')
console.log(' # # # # ')
console.log(' # # # # ')
console.log(' # # ### ')
console.log(' # # # # ')
console.log(' # # # # ')
console.log(' ### # # ')
console.log(' ')
}
//return finishedCallback(status);
if (Config.IS_CONTROLLER) {
// We're in Controller mode.
// - Run Grunt to copy files to the image/tomcat/webapps/ttsvr
// - Run InstallerUtil to copy files to the remote server
// Controller.runGrunt(function() {
// Controller.transfer(function() {
// Log.info('Transfer complete')
process.exit(0)
// });
// })
}
}
exports.createExampleTemplates = function() {
console.log('\nplugins.designer.createExampleTemplates()')
}