UNPKG

tooltwist

Version:
75 lines (66 loc) 2.01 kB
/** * Handle `tooltwist init <mode> ...` */ var Log = require('./log'), Config = require('./config'), Plugin = require('./plugin'), // InitDesigner = require('./initDesigner'), InitDeploy = require('./initDeploy'); exports.handleInitCommandLine = function(ops) { // console.log('handleInitCommandLine()'); if (ops.help) { return usage(); } if (ops.args.length !== 2) { return usage(); } var mode = ops.args[1]; if (mode.indexOf('des') == 0) { // designer mode = 'designer'; } else if (mode.indexOf('dep') == 0) { // deploy checkConfigDoesNotExist(); return InitDeploy.createDefaultConfigFile(); } else if (mode.indexOf('doc') == 0) { mode = 'docker'; } else if (mode.indexOf('dig') == 0) { mode = 'digitalocean'; } else if (mode.indexOf('c') == 0) { mode = 'controller'; } else if (mode.indexOf('w') == 0) { mode = 'war'; } // Get the plugin for this mode var plugin = Plugin.findPlugin(mode); plugin.commandLineInit(); process.exit(0); } function usage() { Log.always() Log.always() Log.always('usage: tooltwist init <mode>') Log.always() Log.always('where mode is one of:') Log.always(' designer Run a stand-alone designer.') Log.always(' deploy Deploy a webdesign project to a remote server.') Log.always(' docker Create a Docker image for a webdesign project.') Log.always(' digitalocean Instantiate and deploy to a Digital Ocean droplet.') // Log.always(' test Run a stand-alone designer.') Log.always(' controller Deploy using the config from the v8.2 Controller.') Log.always(' war Create a WAR file.') Log.always() Log.always('(In most cases the first few characters of the mode is enough)') Log.always() process.exit(1); } /** * Check that we don't already have a tooltwist.js file. */ function checkConfigDoesNotExist() { if (Config.wasFound()) { Log.error(); Log.error('\tERROR: Config already exists at ' + Config.getConfigPath() + '.\n'); process.exit(1); } }