Commits

Anonymous committed b372d0d

Started on the deploy implementation

  • Participants
  • Parent commits 7518670

Comments (0)

Files changed (2)

lib/commands/deploy.js

+var tasks = require('../tasks'),
+    out = require('out');
+
+exports.desc = 'Deploy previously generated output files to the device';
+
+exports.args = {};
+
+// export runner
+exports.run = function(opts, callback) {
+    tasks.run(['deploy'], process.cwd()).on('complete', function(err) {
+        if (err) return out.error(err);
+
+    });
+};
         detached: true,
         stdio: 'inherit'
     },
+    requiredSettings = ['deviceIP', 'devicePass', 'sdkpath'],
     projectFiles = [];
 
 // discover the nature of the project through 
     config.load(function(cfg) {
         // load the local config
         config.loadLocal(targetPath, function(localConfig) {
-            done(null, _.extend({}, cfg, localConfig));
+            var finalConfig = _.extend({}, cfg, localConfig);
+
+            // initialise the toolsPath
+            finalConfig.toolsPath = path.resolve(finalConfig.sdkpath, 'dependencies', 'tools', 'bin');
+
+            // send the results into the taskify context
+            done(null, finalConfig);
         });
     });
 });
 
 task('checkConfig', ['loadConfig'], function(targetPath) {
     var done = this.async(),
-        cfg = this.context.results.loadConfig;
+        cfg = this.context.results.loadConfig,
+        missingSettings = requiredSettings.filter(function(setting) {
+            return typeof cfg[setting] == 'undefined';
+        });
+
+    // if we have missing settings, then abort
+    if (missingSettings.length > 0) {
+        return done(new Error('Missing settings: "' + missingSettings.join(', ') + '" please update worx configuration'));
+    }
 
-    if (! cfg.sdkpath) return done(new Error('sdkpath setting not configured, cannot continue'));
+    // ensure we have the deviceIp
+    if (! cfg.deviceIP) return 
 
     // ensure we have the bbwp command available
     fs.exists(path.resolve(cfg.sdkpath, 'bbwp'), function(exists) {
     ).on('exit', this.async());
 });
 
+task('deploy', ['prepare'], function(targetPath) {
+    var cfg = this.context.results.loadConfig,
+        args = [
+            '-installApp',
+            // '-launchApp',
+            '-password',
+            cfg.devicePass,
+            '-device',
+            cfg.deviceIP,
+            path.resolve(targetPath, 'output', 'device', cfg.projectName + '.bar')
+        ],
+        proc = spawn(path.resolve(cfg.toolsPath, 'blackberry-deploy' + commandExt), args, procOpts);
+
+    
+    out('!{bold}pushing to the device');
+    proc.on('exit', this.async());
+});
+
 exports.run = task.run;