define([ "dcl/dcl", "nxapp/utils/FileUtils", "dojo/node!commander", "dojo/node!fs", "dojo/node!os", "dojo/node!path", "xide/factory/Events", "dojo/has", "xide/model/Base", "xide/utils", 'nxappmain/nxAppBase' ], function (dcl, FileUtils, commander, fs, os,path, Events, has, Base,utils,nxAppBase) { has.add('windows', function () { return os.platform() === 'win32'; }); has.add('osx', function () { return os.platform() === 'darwin'; }); has.add('linux', function () { return os.platform() === 'linux'; }); has.add('arm', function () { return os.arch() === 'arm'; }); return dcl(nxAppBase, { declaredClass: "nxappmain.nxAppExport", profilePath: '/nxappmain/profile_device_server.json', init: function () { if (!this.commander) { //console.error('have no commander!'); commander .version('0.0.1') .option('-f, --file ', 'run a file') .option('-r, --root ', 'root path to Control-Freak') .option('-u, --user ', 'user directory') .option('-t, --target ', 'target directory') .option('-s, --system ', 'path to system scope location') .option('-d, --dist ', 'path to the pre-compiled NodeJS servers') .option('--windows ', 'true/false to export windows NodeJS server') .option('--osx ', 'true/false to export OSX NodeJS server') .option('--linux32 ', 'true/false to export Linux-32 Bit NodeJS server') .option('--linux64 ', 'true/false to export Linux-64 NodeJS server') .option('--arm ', 'true/false to export ARM-v7 NodeJS server') .option('--client ', 'path to client root'); this.commander = commander; this.commander.allowUnknownOption(true); this.commander.parse(process.argv); } if (commander.jhelp) { var options = []; commander.options.map(function (option) { options.push(option); }); console.log(JSON.stringify(options)); process.exit(); } this.profile = this.getProfile(this.profilePath); if(!commander.root){ this.profile.root = FileUtils.resolve('../..'); } if(!commander.target){ this.profile.target = FileUtils.resolve('../../myapp'); } //now mixin command line options into profile utils.mixin(this.profile, this.commander); var dataRoot = path.resolve(this.profile.system); if (fs.existsSync(dataRoot)) { this.profile.system = dataRoot; } else { dataRoot = process.cwd() + '/data/system'; this.profile.system = dataRoot; commander.system = dataRoot; } } }); });