Socket
Socket
Sign inDemoInstall

simctl

Package Overview
Dependencies
2
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.9 to 0.1.0

.jscsrc

15

lib/simctl-extensions.js

@@ -31,10 +31,9 @@ /*

var extensions = {
start : function(deviceid) {
start: function(deviceid) {
var command = util.format('xcrun instruments -w "%s"', deviceid);
return shell.exec(command, { silent: true } );
return shell.exec(command, { silent: true });
},
log : function(deviceid, filepath) {
log: function(deviceid, filepath) {
var tail = new Tail(

@@ -44,5 +43,5 @@ path.join(process.env.HOME, 'Library/Logs/CoreSimulator', deviceid, 'system.log')

tail.on("line", function(data) {
tail.on('line', function(data) {
if (filepath) {
fs.appendFile(filepath, data + "\n", function(error) {
fs.appendFile(filepath, data + '\n', function(error) {
if (error) {

@@ -58,3 +57,3 @@ console.error('ERROR: ', error);

tail.on("error", function(error) {
tail.on('error', function(error) {
console.error('ERROR: ', error);

@@ -61,0 +60,0 @@ });

@@ -26,3 +26,3 @@ /*

var SimctlListParserMode = {
'device' : 0,
'device': 0,
'devicetype': 1,

@@ -34,28 +34,32 @@ 'runtime': 2

this._result = {
'devices' : [],
'devicetypes' : [],
'runtimes' : []
'devices': [],
'devicetypes': [],
'runtimes': []
};
this._mode = null;
this._deviceRuntime = null;
};
}
SimctlListParser.prototype.parse = function(text) {
var that = this;
var _this = this;
clearResult.apply(this);
text.split(/\r?\n/).forEach(function(line){
parseLine.apply(that, [line]);
});
changeMode.apply(this);
return this._result;
text.split(/\r?\n/).forEach(function(line) {
parseLine.apply(_this, [line]);
});
changeMode.apply(this);
return this._result;
};
SimctlListParser.prototype._clear = function() {
clearResult.apply(this);
};
function clearResult() {
this._result = {
'devices' : [],
'devicetypes' : [],
'runtimes' : []
'devices': [],
'devicetypes': [],
'runtimes': []
};

@@ -66,3 +70,3 @@ }

endParse.apply(this);
if (line && line.indexOf('Devices') !== -1) {

@@ -77,6 +81,6 @@ this._mode = SimctlListParserMode.device;

}
};
}
function endParse() {
switch(this._mode) {
switch (this._mode) {
case SimctlListParserMode.device:

@@ -91,3 +95,3 @@ if (this._deviceRuntime) {

function parseLine(line) {
if (line.indexOf('==') === 0) {

@@ -97,3 +101,3 @@ changeMode.apply(this, [line]);

}
switch (this._mode) {

@@ -112,2 +116,7 @@ case SimctlListParserMode.device:

function isUUID(text) {
var regExp = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
return regExp.test(text);
}
function parseDevice(line) {

@@ -118,24 +127,35 @@ if (line.indexOf('--') === 0) {

}
// example: iPhone 4s (3717C817-6AD7-42B8-ACF3-405CB9E96375) (Shutdown) (unavailable)
// example: iPad Pro (9.7 inch) (1C5590C8-8AE7-4C27-AD06-84C801702945) (Shutdown) (unavailable)
// the last capture group might not be there if available
// the first parenthesized group might be part of the name
var available = false;
var regExp = /(.*)\(([^)]+)\)\s\(([^)]+)\)\s\(([^)]+)\)/;
var matches = regExp.exec(line);
if (!matches) {
regExp = /(.*)\(([^)]+)\)\s\(([^)]+)\)/;
matches = regExp.exec(line);
available = true;
var regExp = /([^)]*)\s\(([^)]+)\)/g;
var items = [];
var matches;
while ((matches = regExp.exec(line)) !== null) {
if (matches[1].length > 0) {
if (isUUID(matches[2])) { // next is uuid, so push both name and id
items.push(matches[1]);
items.push(matches[2]);
} else { // name is in the next paren. group (not UUID), use whole match
items.push(matches[0]);
}
} else { // no match for name, just push second match
items.push(matches[2]);
}
}
if (matches) {
if (items.length) {
var obj = {
'name' : matches[1].trim(),
'id' : matches[2].trim(),
'state' : matches[3].trim(),
'available' : available
'name': items[0].trim(),
'id': items[1].trim(),
'state': items[2].trim(),
'available': items[3] === undefined
};
this._deviceRuntime.devices.push(obj);

@@ -149,7 +169,7 @@ }

}
var runtime = line;
var regExp = /--\s(.*)\s--/;
var matches = regExp.exec(line);
if (matches) {

@@ -160,6 +180,6 @@ runtime = matches[1];

var obj = {
'runtime' : runtime,
'devices' : []
'runtime': runtime,
'devices': []
};
this._deviceRuntime = obj;

@@ -172,9 +192,9 @@ }

var matches = regExp.exec(line);
if (matches) {
var obj = {
'name' : matches[1].trim(),
'id' : matches[2].trim()
'name': matches[1].trim(),
'id': matches[2].trim()
};
this._result.devicetypes.push(obj);

@@ -185,3 +205,5 @@ }

function parseRuntime(line) {
// Example: iOS 7.0 (7.0 - Unknown) (com.apple.CoreSimulator.SimRuntime.iOS-7-0) (unavailable, runtime path not found)
// Example:
// iOS 7.0 (7.0 - Unknown)
// (com.apple.CoreSimulator.SimRuntime.iOS-7-0) (unavailable, runtime path not found)
// the last capture group might not be there if available

@@ -197,11 +219,11 @@ var available = false;

}
if (matches) {
var obj = {
'name' : matches[1].trim(),
'build' : matches[2].trim(),
'id' : matches[3].trim(),
'available' : available
'name': matches[1].trim(),
'build': matches[2].trim(),
'id': matches[3].trim(),
'available': available
};
this._result.runtimes.push(obj);

@@ -208,0 +230,0 @@ }

{
"name": "simctl",
"version": "0.0.9",
"version": "0.1.0",
"description": "library for Xcode simctl utility on OS X",

@@ -13,2 +13,15 @@ "repository": {

"tail": "^0.4.0"
},
"devDependencies": {
"jasmine-node": "^1.14.5",
"jscs": "^2.11.0",
"jshint": "^2.9.1"
},
"scripts": {
"test": "npm run jasmine",
"posttest": "npm run jshint",
"jshint": "jshint lib ./simctl.js",
"postjshint": "npm run jscs",
"jscs": "jscs lib ./simctl.js",
"jasmine": "jasmine-node --captureExceptions --color spec"
},

@@ -15,0 +28,0 @@ "keywords": [

@@ -32,16 +32,15 @@ /*

exports = module.exports = {
exports = module.exports = {
set noxpc(b) {
this._noxpc = b;
},
get noxpc() {
return this._noxpc;
},
extensions : SimCtlExtensions,
check_prerequisites : function() {
extensions: SimCtlExtensions,
check_prerequisites: function() {
var command = util.format('xcrun simctl help');

@@ -52,67 +51,67 @@ var obj = shell.exec(command, {silent: true});

obj.output = 'simctl was not found.\n';
obj.output += 'Check that you have Xcode 6.x installed:\n';
obj.output += 'Check that you have Xcode 7.x installed:\n';
obj.output += '\txcodebuild --version';
obj.output += 'Check that you have Xcode 6.x selected:\n';
obj.output += 'Check that you have Xcode 7.x selected:\n';
obj.output += '\txcode-select --print-path';
}
return obj;
},
create : function(name, device_type_id, runtime_id) {
create: function(name, device_type_id, runtime_id) {
var command = util.format('xcrun simctl create "%s" "%s" "%s"', name, device_type_id, runtime_id);
return shell.exec(command);
},
del : function(device) {
del: function(device) {
var command = util.format('xcrun simctl delete "%s"', device);
return shell.exec(command);
},
erase : function(device) {
erase: function(device) {
var command = util.format('xcrun simctl erase "%s"', device);
return shell.exec(command);
},
boot : function(device) {
boot: function(device) {
var command = util.format('xcrun simctl boot "%s"', device);
return shell.exec(command);
},
shutdown : function(device) {
shutdown: function(device) {
var command = util.format('xcrun simctl shutdown "%s"', device);
return shell.exec(command);
},
rename : function(device, name) {
rename: function(device, name) {
var command = util.format('xcrun simctl rename "%s" "%s"', device, name);
return shell.exec(command);
},
getenv : function(device, variable_name) {
getenv: function(device, variable_name) {
var command = util.format('xcrun simctl getenv "%s" "%s"', device, variable_name);
return shell.exec(command);
},
openurl : function(device, url) {
openurl: function(device, url) {
var command = util.format('xcrun simctl openurl "%s" "%s"', device, url);
return shell.exec(command);
},
addphoto : function(device, path) {
addphoto: function(device, path) {
var command = util.format('xcrun simctl addphoto "%s" "%s"', device, path);
return shell.exec(command);
},
install : function(device, path) {
install: function(device, path) {
var command = util.format('xcrun simctl install "%s" "%s"', device, path);
return shell.exec(command);
},
uninstall : function(device, app_identifier) {
uninstall: function(device, app_identifier) {
var command = util.format('xcrun simctl uninstall "%s" "%s"', device, app_identifier);
return shell.exec(command);
},
launch : function(wait_for_debugger, device, app_identifier, argv) {
launch: function(wait_for_debugger, device, app_identifier, argv) {
var wait_flag = '';

@@ -122,15 +121,16 @@ if (wait_for_debugger) {

}
var argv_expanded = '';
if (argv.length > 0) {
argv_expanded = argv.map(function(arg){
return "'" + arg + "'";
}).join(" ");
argv_expanded = argv.map(function(arg) {
return '\'' + arg + '\'';
}).join(' ');
}
var command = util.format('xcrun simctl launch %s "%s" "%s" %s', wait_flag, device, app_identifier, argv_expanded);
var command = util.format('xcrun simctl launch %s "%s" "%s" %s',
wait_flag, device, app_identifier, argv_expanded);
return shell.exec(command);
},
spawn : function(wait_for_debugger, arch, device, path_to_executable, argv) {
spawn: function(wait_for_debugger, arch, device, path_to_executable, argv) {
var wait_flag = '';

@@ -145,18 +145,19 @@ if (wait_for_debugger) {

}
var argv_expanded = '';
if (argv.length > 0) {
argv_expanded = argv.map(function(arg){
return "'" + arg + "'";
}).join(" ");
argv_expanded = argv.map(function(arg) {
return '\'' + arg + '\'';
}).join(' ');
}
var command = util.format('xcrun simctl spawn %s %s "%s" "%s" %s', wait_flag, arch_flag, device, path_to_executable, argv_expanded);
var command = util.format('xcrun simctl spawn %s %s "%s" "%s" %s',
wait_flag, arch_flag, device, path_to_executable, argv_expanded);
return shell.exec(command);
},
list : function(options) {
list: function(options) {
var sublist = '';
options = options || {};
if (options.devices) {

@@ -169,3 +170,3 @@ sublist = 'devices';

}
var command = util.format('xcrun simctl list %s', sublist);

@@ -178,3 +179,3 @@ var obj = shell.exec(command, { silent: options.silent });

obj.json = parser.parse(obj.output);
} catch(err) {
} catch (err) {
console.error(err.stack);

@@ -186,17 +187,17 @@ }

},
notify_post : function(device, notification_name) {
notify_post: function(device, notification_name) {
var command = util.format('xcrun simctl notify_post "%s" "%s"', device, notification_name);
return shell.exec(command);
},
icloud_sync : function(device) {
icloud_sync: function(device) {
var command = util.format('xcrun simctl icloud_sync "%s"', device);
return shell.exec(command);
},
help : function(subcommand) {
help: function(subcommand) {
var command = util.format('xcrun simctl help "%s"', subcommand);
return shell.exec(command);
}
};
};
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc