You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by dp...@apache.org on 2019/04/17 18:44:52 UTC
[cordova-ios] branch master updated: More logging for simulator
selection and deployment (#596)
This is an automated email from the ASF dual-hosted git repository.
dpogue pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cordova-ios.git
The following commit(s) were added to refs/heads/master by this push:
new da5b69d More logging for simulator selection and deployment (#596)
da5b69d is described below
commit da5b69d62f2732039e9c82e603a24e291b086847
Author: Jan Piotrowski <pi...@gmail.com>
AuthorDate: Wed Apr 17 20:44:47 2019 +0200
More logging for simulator selection and deployment (#596)
* remove wrong comment about default emulator
* add logging about deployment
* add comment back, minus wrong default
* quote target string
* log simulator start command
* prefix log from simulator to make it recognizable
* add missing space in command logging
* fix log prefix (data comes from ios-sim, not simulator)
* use patched ios-sim with additional output
* fix package.json maybe?
* switch to janpio/ios-sim#802
* better logging about target
* fix
* fix eslint stuff
* try to use superspawn instead of cp
* stdio=pipe
* iterate
* Update package.json
* review feedback
* Minor improvements to logging
---
bin/templates/scripts/cordova/lib/build.js | 6 ++++--
bin/templates/scripts/cordova/lib/run.js | 27 +++++++++++++++++++--------
2 files changed, 23 insertions(+), 10 deletions(-)
diff --git a/bin/templates/scripts/cordova/lib/build.js b/bin/templates/scripts/cordova/lib/build.js
index 4270c47..7a36c06 100644
--- a/bin/templates/scripts/cordova/lib/build.js
+++ b/bin/templates/scripts/cordova/lib/build.js
@@ -160,12 +160,13 @@ module.exports.run = function (buildOpts) {
if (!theTarget) {
return getDefaultSimulatorTarget().then(function (defaultTarget) {
emulatorTarget = defaultTarget.name;
- events.emit('log', 'Building for ' + emulatorTarget + ' Simulator');
+ events.emit('warn', `No simulator found for "${newTarget}. Falling back to the default target.`);
+ events.emit('log', `Building for "${emulatorTarget}" Simulator (${defaultTarget.identifier}, ${defaultTarget.simIdentifier}).`);
return emulatorTarget;
});
} else {
emulatorTarget = theTarget.name;
- events.emit('log', 'Building for ' + emulatorTarget + ' Simulator');
+ events.emit('log', `Building for "${emulatorTarget}" Simulator (${theTarget.identifier}, ${theTarget.simIdentifier}).`);
return emulatorTarget;
}
});
@@ -217,6 +218,7 @@ module.exports.run = function (buildOpts) {
events.emit('log', 'Building project: ' + path.join(projectPath, projectName + '.xcworkspace'));
events.emit('log', '\tConfiguration: ' + configuration);
events.emit('log', '\tPlatform: ' + (buildOpts.device ? 'device' : 'emulator'));
+ events.emit('log', '\tTarget: ' + emulatorTarget);
var buildOutputDir = path.join(projectPath, 'build', (buildOpts.device ? 'device' : 'emulator'));
diff --git a/bin/templates/scripts/cordova/lib/run.js b/bin/templates/scripts/cordova/lib/run.js
index f9e5761..f21fee6 100644
--- a/bin/templates/scripts/cordova/lib/run.js
+++ b/bin/templates/scripts/cordova/lib/run.js
@@ -19,7 +19,6 @@
var Q = require('q');
var path = require('path');
-var cp = require('child_process');
var build = require('./build');
var shell = require('shelljs');
var superspawn = require('cordova-common').superspawn;
@@ -159,6 +158,7 @@ function checkDeviceConnected () {
* @return {Promise} Resolves when deploy succeeds otherwise rejects
*/
function deployToDevice (appPath, target, extraArgs) {
+ events.emit('log', 'Deploying to device');
// Deploying to device...
if (target) {
return superspawn.spawn('ios-deploy', ['--justlaunch', '-d', '-b', appPath, '-i', target].concat(extraArgs), { printCommand: true, stdio: 'inherit' });
@@ -174,8 +174,9 @@ function deployToDevice (appPath, target, extraArgs) {
* @return {Promise} Resolves when deploy succeeds otherwise rejects
*/
function deployToSim (appPath, target) {
- // Select target device for emulator. Default is 'iPhone-6'
+ events.emit('log', 'Deploying to simulator');
if (!target) {
+ // Select target device for emulator
return require('./list-emulator-images').run()
.then(function (emulators) {
if (emulators.length > 0) {
@@ -186,7 +187,7 @@ function deployToSim (appPath, target) {
target = emulator;
}
});
- events.emit('log', 'No target specified for emulator. Deploying to ' + target + ' simulator');
+ events.emit('log', `No target specified for emulator. Deploying to "${target}" simulator.`);
return startSim(appPath, target);
});
} else {
@@ -200,12 +201,22 @@ function startSim (appPath, target) {
return iossimLaunch(appPath, 'com.apple.CoreSimulator.SimDeviceType.' + target, logPath, '--exit');
}
-function iossimLaunch (app_path, devicetypeid, log, exit) {
+function iossimLaunch (appPath, devicetypeid, log, exit) {
var f = path.resolve(path.dirname(require.resolve('ios-sim')), 'bin', 'ios-sim');
- var proc = cp.spawn(f, ['launch', app_path, '--devicetypeid', devicetypeid, '--log', log, exit]);
- proc.stdout.on('data', (data) => {
- console.log(data.toString());
- });
+ var params = ['launch', appPath, '--devicetypeid', devicetypeid, '--log', log, exit];
+
+ return superspawn.spawn(f, params, { cwd: projectPath, printCommand: true })
+ .progress(function (stdio) {
+ if (stdio.stderr) {
+ events.emit('error', `[ios-sim] ${stdio.stderr}`);
+ }
+ if (stdio.stdout) {
+ events.emit('log', `[ios-sim] ${stdio.stdout.trim()}`);
+ }
+ })
+ .then(function (result) {
+ events.emit('log', 'Simulator successfully started via `ios-sim`.');
+ });
}
function listDevices () {
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org