New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ios-sim-portable

Package Overview
Dependencies
Maintainers
5
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ios-sim-portable - npm Package Compare versions

Comparing version 1.6.1 to 2.0.0

.vscode/settings.json

2

bin/ios-sim-portable.js
#!/usr/bin/env node
require("../lib/ios-sim.js");
require("../lib/ios-sim-standalone.js");
"use strict";
var child_process = require("child_process");
var Future = require("fibers/future");
var util = require("util");
function exec(command, opts) {
var future = new Future();
child_process.exec(command, function (error, stdout, stderr) {
if (error) {
if (opts && opts.skipError) {
future.return(error);
}
else {
future.throw(new Error("Error " + error.message + " while executing " + command + "."));
}
const child_process = require("child_process");
function execSync(command, opts) {
try {
return child_process.execSync(command, opts);
}
catch (err) {
if (opts && opts.skipError) {
return err;
}
else {
future.return(stdout ? stdout.toString() : "");
throw (new Error(`Error ${err.message} while executing ${command}.`));
}
});
return future;
}
}
exports.exec = exec;
exports.execSync = execSync;
function spawn(command, args, opts) {
var future = new Future();
var capturedOut = "";
var capturedErr = "";
var childProcess = child_process.spawn(command, args);
if (childProcess.stdout) {
childProcess.stdout.on("data", function (data) {
capturedOut += data;
});
}
if (childProcess.stderr) {
childProcess.stderr.on("data", function (data) {
capturedErr += data;
});
}
childProcess.on("close", function (arg) {
var exitCode = typeof arg === 'number' ? arg : arg && arg.code;
if (exitCode === 0) {
future.return(capturedOut ? capturedOut.trim() : null);
return new Promise((resolve, reject) => {
let capturedOut = "";
let capturedErr = "";
let childProcess = child_process.spawn(command, args);
if (childProcess.stdout) {
childProcess.stdout.on("data", (data) => {
capturedOut += data;
});
}
else {
if (opts && opts.skipError) {
future.return(capturedErr);
if (childProcess.stderr) {
childProcess.stderr.on("data", (data) => {
capturedErr += data;
});
}
childProcess.on("close", (arg) => {
var exitCode = typeof arg === 'number' ? arg : arg && arg.code;
if (exitCode === 0) {
resolve(capturedOut ? capturedOut.trim() : null);
}
else {
future.throw(new Error(util.format("Command %s with arguments %s failed with exit code %s. Error output:\n %s", command, args.join(" "), exitCode, capturedErr)));
if (opts && opts.skipError) {
resolve(capturedErr);
}
else {
reject(new Error(`Command ${command} with arguments ${args.join(" ")} failed with exit code ${exitCode}. Error output:\n ${capturedErr}`));
}
}
}
});
});
return future;
}
exports.spawn = spawn;
"use strict";
var fs = require("fs");
var path = require("path");
const fs = require("fs");
const path = require("path");
require("colors");
var errors = require("./errors");
var options = require("./options");
var CommandExecutor = (function () {
function CommandExecutor() {
}
CommandExecutor.prototype.execute = function () {
const errors = require("./errors");
const options = require("./options");
class CommandExecutor {
execute() {
var commandName = this.getCommandName();
var commandArguments = this.getCommandArguments();
return this.executeCore(commandName, commandArguments);
};
CommandExecutor.prototype.executeCore = function (commandName, commandArguments) {
return (function () {
try {
var filePath = path.join(__dirname, "commands", commandName + ".js");
if (fs.existsSync(filePath)) {
var command = new (require(filePath).Command)();
if (!command) {
errors.fail("Unable to resolve commandName %s", commandName);
}
command.execute(commandArguments).wait();
}
executeCore(commandName, commandArguments) {
try {
let filePath = path.join(__dirname, "commands", commandName + ".js");
if (fs.existsSync(filePath)) {
var command = new (require(filePath).Command)();
if (!command) {
errors.fail("Unable to resolve commandName %s", commandName);
}
command.execute(commandArguments);
}
catch (e) {
if (options.debug) {
throw e;
}
else {
console.log("\x1B[31;1m" + e.message + "\x1B[0m");
}
}
catch (e) {
if (options.debug) {
throw e;
}
}).future()();
};
CommandExecutor.prototype.getCommandArguments = function () {
else {
console.log("\x1B[31;1m" + e.message + "\x1B[0m");
}
}
}
getCommandArguments() {
var remaining = options._;
return remaining.length > 1 ? remaining.slice(1) : [];
};
CommandExecutor.prototype.getCommandName = function () {
}
getCommandName() {
var remaining = options._;
return remaining.length > 0 ? remaining[0].toLowerCase() : "help";
};
return CommandExecutor;
})();
}
}
exports.CommandExecutor = CommandExecutor;
"use strict";
var iphoneSimulatorLibPath = require("./../iphone-simulator");
var Command = (function () {
function Command() {
}
Command.prototype.execute = function (args) {
const iphoneSimulatorLibPath = require("./../iphone-simulator");
class Command {
execute(args) {
var iphoneSimulator = new iphoneSimulatorLibPath.iPhoneSimulator();
return iphoneSimulator.printDeviceTypes();
};
return Command;
})();
}
}
exports.Command = Command;
"use strict";
var fs = require("fs");
var path = require("path");
var util = require("util");
var Command = (function () {
function Command() {
const fs = require("fs");
const path = require("path");
const util = require("util");
class Command {
execute(args) {
var topic = (args[0] || "").toLowerCase();
if (topic === "help") {
topic = "";
}
var helpContent = fs.readFileSync(path.join(__dirname, "../../resources/help.txt")).toString();
var pattern = util.format("--\\[%s\\]--((.|[\\r\\n])+?)--\\[/\\]--", this.escape(topic));
var regex = new RegExp(pattern);
var match = regex.exec(helpContent);
if (match) {
var helpText = match[1].trim();
console.log(helpText);
}
}
Command.prototype.execute = function (args) {
var _this = this;
return (function () {
var topic = (args[0] || "").toLowerCase();
if (topic === "help") {
topic = "";
}
var helpContent = fs.readFileSync(path.join(__dirname, "../../resources/help.txt")).toString();
var pattern = util.format("--\\[%s\\]--((.|[\\r\\n])+?)--\\[/\\]--", _this.escape(topic));
var regex = new RegExp(pattern);
var match = regex.exec(helpContent);
if (match) {
var helpText = match[1].trim();
console.log(helpText);
}
}).future()();
};
Command.prototype.escape = function (s) {
escape(s) {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
};
return Command;
})();
}
}
exports.Command = Command;
"use strict";
var iphoneSimulatorLibPath = require("./../iphone-simulator");
var Command = (function () {
function Command() {
}
Command.prototype.execute = function (args) {
const iphoneSimulatorLibPath = require("./../iphone-simulator");
class Command {
execute(args) {
var iphoneSimulator = new iphoneSimulatorLibPath.iPhoneSimulator();
return iphoneSimulator.run(args[0], args[1]);
};
return Command;
})();
}
}
exports.Command = Command;
"use strict";
var iphoneSimulatorLibPath = require("./../iphone-simulator");
var Command = (function () {
function Command() {
}
Command.prototype.execute = function (args) {
const iphoneSimulatorLibPath = require("./../iphone-simulator");
class Command {
execute(args) {
var iphoneSimulator = new iphoneSimulatorLibPath.iPhoneSimulator();
return iphoneSimulator.sendNotification(args[0]);
};
return Command;
})();
}
}
exports.Command = Command;
"use strict";
var iphoneSimulatorLibPath = require("./../iphone-simulator");
var Command = (function () {
function Command() {
}
Command.prototype.execute = function (args) {
const iphoneSimulatorLibPath = require("./../iphone-simulator");
class Command {
execute(args) {
var iphoneSimulator = new iphoneSimulatorLibPath.iPhoneSimulator();
return iphoneSimulator.printSDKS();
};
return Command;
})();
}
}
exports.Command = Command;
"use strict";
var util = require("util");
function fail(errorMessage) {
var args = [];
for (var _i = 1; _i < arguments.length; _i++) {
args[_i - 1] = arguments[_i];
}
const util = require("util");
function fail(errorMessage, ...args) {
args.unshift(errorMessage);

@@ -9,0 +5,0 @@ throw new Error(util.format.apply(null, args));

"use strict";
var _ = require("lodash");
var Fiber = require("fibers");
var Future = require("fibers/future");
var commandExecutorLibPath = require("./command-executor");
var fiber = Fiber(function () {
var commandExecutor = new commandExecutorLibPath.CommandExecutor();
commandExecutor.execute().wait();
Future.assertNoFutureLeftBehind();
});
fiber.run();
const _ = require("lodash");
function getSimulator() {
var libraryPath = require("./iphone-simulator");
var obj = new libraryPath.iPhoneSimulator();
let libraryPath = require("./iphone-simulator");
let obj = new libraryPath.iPhoneSimulator();
return obj.createSimulator();
}
global.publicApi = {};
Object.defineProperty(global.publicApi, "getRunningSimulator", {
get: function () {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
var future = new Future();
var libraryPath = require("./iphone-simulator-xcode-7");
var simulator = new libraryPath.XCode7Simulator();
var repeatCount = 30;
var timer = setInterval(function () {
Fiber(function () {
var result = simulator.getBootedDevice.apply(simulator, args).wait();
if ((result || !repeatCount) && !future.isResolved()) {
const publicApi = {};
Object.defineProperty(publicApi, "getRunningSimulator", {
get: () => {
return (...args) => {
let isResolved = false;
return new Promise((resolve, reject) => {
let libraryPath = require("./iphone-simulator-xcode-simctl");
let simulator = new libraryPath.XCodeSimctlSimulator();
let repeatCount = 30;
let timer = setInterval(() => {
let result = simulator.getBootedDevice.apply(simulator, args);
if ((result || !repeatCount) && !isResolved) {
isResolved = true;
clearInterval(timer);
future.return(result);
resolve(result);
}
repeatCount--;
}).run();
}, 500);
return future.wait();
}, 500);
});
};
}
});
Object.defineProperty(global.publicApi, "getApplicationPath", {
get: function () {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
var simulator = getSimulator().wait();
var result = simulator.getApplicationPath.apply(simulator, args).wait();
Object.defineProperty(publicApi, "getApplicationPath", {
get: () => {
return (...args) => {
let simulator = getSimulator();
let result = simulator.getApplicationPath.apply(simulator, args);
return result;

@@ -56,12 +39,8 @@ };

});
Object.defineProperty(global.publicApi, "getInstalledApplications", {
get: function () {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
var simulator = getSimulator().wait();
var installedApplications = simulator.getInstalledApplications.apply(simulator, args).wait();
var result = _.map(installedApplications, function (application) { return application.appIdentifier; });
Object.defineProperty(publicApi, "getInstalledApplications", {
get: () => {
return (...args) => {
let simulator = getSimulator();
let installedApplications = simulator.getInstalledApplications.apply(simulator, args);
let result = _.map(installedApplications, application => application.appIdentifier);
return result;

@@ -78,11 +57,7 @@ };

"startSimulator",
"getSimulatorName"].forEach(function (methodName) {
Object.defineProperty(global.publicApi, methodName, {
get: function () {
return function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i - 0] = arguments[_i];
}
var simulator = getSimulator().wait();
"getSimulatorName"].forEach(methodName => {
Object.defineProperty(publicApi, methodName, {
get: () => {
return (...args) => {
let simulator = getSimulator();
return simulator[methodName].apply(simulator, args);

@@ -93,2 +68,2 @@ };

});
module.exports = global.publicApi;
module.exports = publicApi;
"use strict";
var childProcess = require("./child-process");
var xcode = require("./xcode");
var Future = require("fibers/future");
var fs = require("fs");
var path = require("path");
var _ = require("lodash");
var bplistParser = require("bplist-parser");
var plist = require("plist");
var osenv = require("osenv");
var isDeviceLogOperationStarted = false;
var pid;
var deviceLogChildProcess;
const childProcess = require("./child-process");
const xcode = require("./xcode");
const fs = require("fs");
const path = require("path");
const _ = require("lodash");
let bplistParser = require("bplist-parser");
let plist = require("plist");
let osenv = require("osenv");
let isDeviceLogOperationStarted = false;
let pid;
let deviceLogChildProcess;
function getInstalledApplications(deviceId) {
return (function () {
var rootApplicationsPath = path.join(osenv.home(), "/Library/Developer/CoreSimulator/Devices/" + deviceId + "/data/Containers/Bundle/Application");
if (!fs.existsSync(rootApplicationsPath)) {
rootApplicationsPath = path.join(osenv.home(), "/Library/Developer/CoreSimulator/Devices/" + deviceId + "/data/Applications");
let rootApplicationsPath = path.join(osenv.home(), `/Library/Developer/CoreSimulator/Devices/${deviceId}/data/Containers/Bundle/Application`);
if (!fs.existsSync(rootApplicationsPath)) {
rootApplicationsPath = path.join(osenv.home(), `/Library/Developer/CoreSimulator/Devices/${deviceId}/data/Applications`);
}
let applicationGuids = fs.readdirSync(rootApplicationsPath);
let result = [];
_.each(applicationGuids, applicationGuid => {
let fullApplicationPath = path.join(rootApplicationsPath, applicationGuid);
if (fs.statSync(fullApplicationPath).isDirectory()) {
let applicationDirContents = fs.readdirSync(fullApplicationPath);
let applicationName = _.find(applicationDirContents, fileName => path.extname(fileName) === ".app");
let plistFilePath = path.join(fullApplicationPath, applicationName, "Info.plist");
result.push({
guid: applicationGuid,
appIdentifier: getBundleIdentifier(plistFilePath),
path: path.join(fullApplicationPath, applicationName)
});
}
var applicationGuids = fs.readdirSync(rootApplicationsPath);
var result = [];
_.each(applicationGuids, function (applicationGuid) {
var fullApplicationPath = path.join(rootApplicationsPath, applicationGuid);
if (fs.statSync(fullApplicationPath).isDirectory()) {
var applicationDirContents = fs.readdirSync(fullApplicationPath);
var applicationName = _.find(applicationDirContents, function (fileName) { return path.extname(fileName) === ".app"; });
var plistFilePath = path.join(fullApplicationPath, applicationName, "Info.plist");
result.push({
guid: applicationGuid,
appIdentifier: getBundleIdentifier(plistFilePath).wait(),
path: path.join(fullApplicationPath, applicationName)
});
}
});
return result;
}).future()();
});
return result;
}

@@ -46,6 +43,6 @@ exports.getInstalledApplications = getInstalledApplications;

if (deviceLogChildProcess.stdout) {
deviceLogChildProcess.stdout.on("data", function (data) {
var dataAsString = data.toString();
deviceLogChildProcess.stdout.on("data", (data) => {
let dataAsString = data.toString();
if (pid) {
if (dataAsString.indexOf("[" + pid + "]") > -1) {
if (dataAsString.indexOf(`[${pid}]`) > -1) {
process.stdout.write(dataAsString);

@@ -60,6 +57,6 @@ }

if (deviceLogChildProcess.stderr) {
deviceLogChildProcess.stderr.on("data", function (data) {
var dataAsString = data.toString();
deviceLogChildProcess.stderr.on("data", (data) => {
let dataAsString = data.toString();
if (pid) {
if (dataAsString.indexOf("[" + pid + "]") > -1) {
if (dataAsString.indexOf(`[${pid}]`) > -1) {
process.stdout.write(dataAsString);

@@ -80,3 +77,3 @@ }

if (!isDeviceLogOperationStarted) {
var logFilePath = path.join(osenv.home(), "Library", "Logs", "CoreSimulator", deviceId, "system.log");
let logFilePath = path.join(osenv.home(), "Library", "Logs", "CoreSimulator", deviceId, "system.log");
deviceLogChildProcess = require("child_process").spawn("tail", ['-f', '-n', '1', logFilePath]);

@@ -89,33 +86,17 @@ isDeviceLogOperationStarted = true;

function startSimulator(deviceId) {
return (function () {
var simulatorPath = path.resolve(xcode.getPathFromXcodeSelect().wait(), "Applications", "Simulator.app");
var args = [simulatorPath, '--args', '-CurrentDeviceUDID', deviceId];
childProcess.spawn("open", args).wait();
}).future()();
let simulatorPath = path.resolve(xcode.getPathFromXcodeSelect(), "Applications", "Simulator.app");
let args = ["open", simulatorPath, '--args', '-CurrentDeviceUDID', deviceId];
childProcess.execSync(args.join(" "));
}
exports.startSimulator = startSimulator;
function parseFile(plistFilePath) {
var future = new Future();
bplistParser.parseFile(plistFilePath, function (err, obj) {
if (err) {
future.throw(err);
}
else {
future.return(obj);
}
});
return future;
}
function getBundleIdentifier(plistFilePath) {
return (function () {
var plistData;
try {
plistData = parseFile(plistFilePath).wait()[0];
}
catch (err) {
var content = fs.readFileSync(plistFilePath).toString();
plistData = plist.parse(content);
}
return plistData && plistData.CFBundleIdentifier;
}).future()();
let plistData;
try {
plistData = bplistParser.parseFileSync(plistFilePath)[0];
}
catch (err) {
let content = fs.readFileSync(plistFilePath).toString();
plistData = plist.parse(content);
}
return plistData && plistData.CFBundleIdentifier;
}
"use strict";
var options = require("./options");
var IPhoneSimulatorNameGetter = (function () {
function IPhoneSimulatorNameGetter() {
}
IPhoneSimulatorNameGetter.prototype.getSimulatorName = function (deviceName) {
const options = require("./options");
class IPhoneSimulatorNameGetter {
getSimulatorName(deviceName) {
if (!this._simulatorName) {

@@ -11,5 +9,4 @@ this._simulatorName = options.device || deviceName || this.defaultDeviceIdentifier;

return this._simulatorName;
};
return IPhoneSimulatorNameGetter;
})();
}
}
exports.IPhoneSimulatorNameGetter = IPhoneSimulatorNameGetter;
"use strict";
var fs = require("fs");
var os = require("os");
var errors = require("./errors");
var options = require("./options");
var xcode = require("./xcode");
var xcode8SimulatorLib = require("./iphone-simulator-xcode-8");
var xcode7SimulatorLib = require("./iphone-simulator-xcode-7");
var xcode6SimulatorLib = require("./iphone-simulator-xcode-6");
var xcode5SimulatorLib = require("./iphone-simulator-xcode-5");
var _ = require("lodash");
var $ = require("nodobjc");
var iPhoneSimulator = (function () {
function iPhoneSimulator() {
const fs = require("fs");
const os = require("os");
const errors = require("./errors");
const options = require("./options");
const iphone_simulator_xcode_simctl_1 = require("./iphone-simulator-xcode-simctl");
const _ = require("lodash");
class iPhoneSimulator {
constructor() {
this.simulator = null;
this.simulator = this.createSimulator().wait();
this.simulator = this.createSimulator();
}
iPhoneSimulator.prototype.run = function (applicationPath, applicationIdentifier) {
run(applicationPath, applicationIdentifier) {
if (!fs.existsSync(applicationPath)) {

@@ -23,37 +18,31 @@ errors.fail("Path does not exist ", applicationPath);

if (options.device) {
var deviceNames = _.unique(_.map(this.simulator.getDevices().wait(), function (device) { return device.name; }));
let deviceNames = _.unique(_.map(this.simulator.getDevices(), (device) => device.name));
if (!_.contains(deviceNames, options.device)) {
errors.fail("Unable to find device " + options.device + ". The valid device names are " + deviceNames.join(", "));
errors.fail(`Unable to find device ${options.device}. The valid device names are ${deviceNames.join(", ")}`);
}
}
var sdkVersion = options.sdkVersion || options.sdk;
let sdkVersion = options.sdkVersion || options.sdk;
if (sdkVersion) {
var runtimeVersions = _.unique(_.map(this.simulator.getDevices().wait(), function (device) { return device.runtimeVersion; }));
let runtimeVersions = _.unique(_.map(this.simulator.getDevices(), (device) => device.runtimeVersion));
if (!_.contains(runtimeVersions, sdkVersion)) {
errors.fail("Unable to find sdk " + sdkVersion + ". The valid runtime versions are " + runtimeVersions.join(", "));
errors.fail(`Unable to find sdk ${sdkVersion}. The valid runtime versions are ${runtimeVersions.join(", ")}`);
}
}
return this.simulator.run(applicationPath, applicationIdentifier);
};
iPhoneSimulator.prototype.printDeviceTypes = function () {
var _this = this;
return (function () {
var devices = _this.simulator.getDevices().wait();
_.each(devices, function (device) { return console.log("Device Identifier: " + device.fullId + ". " + os.EOL + "Runtime version: " + device.runtimeVersion + " " + os.EOL); });
}).future()();
};
iPhoneSimulator.prototype.printSDKS = function () {
var _this = this;
return (function () {
var sdks = _this.simulator.getSdks().wait();
_.each(sdks, function (sdk) {
var output = " Display Name: " + sdk.displayName + " " + os.EOL + " Version: " + sdk.version + " " + os.EOL;
if (sdk.rootPath) {
output += " Root path: " + sdk.rootPath + " " + os.EOL;
}
console.log(output);
});
}).future()();
};
iPhoneSimulator.prototype.sendNotification = function (notification) {
}
printDeviceTypes() {
let devices = this.simulator.getDevices();
_.each(devices, device => console.log(`Device Identifier: ${device.fullId}. ${os.EOL}Runtime version: ${device.runtimeVersion} ${os.EOL}`));
}
printSDKS() {
let sdks = this.simulator.getSdks();
_.each(sdks, (sdk) => {
let output = ` Display Name: ${sdk.displayName} ${os.EOL} Version: ${sdk.version} ${os.EOL}`;
if (sdk.rootPath) {
output += ` Root path: ${sdk.rootPath} ${os.EOL}`;
}
console.log(output);
});
}
sendNotification(notification) {
if (!notification) {

@@ -63,28 +52,7 @@ errors.fail("Notification required.");

return this.simulator.sendNotification(notification);
};
iPhoneSimulator.prototype.createSimulator = function () {
return (function () {
var xcodeVersionData = xcode.getXcodeVersionData().wait();
var majorVersion = xcodeVersionData.major;
var simulator = null;
if (majorVersion === "8") {
simulator = new xcode8SimulatorLib.XCode8Simulator();
}
else if (majorVersion === "7") {
simulator = new xcode7SimulatorLib.XCode7Simulator();
}
else if (majorVersion === "6") {
simulator = new xcode6SimulatorLib.XCode6Simulator();
}
else if (majorVersion === "5") {
simulator = new xcode5SimulatorLib.XCode5Simulator();
}
else {
errors.fail("Unsupported xcode version " + xcodeVersionData.major + ".");
}
return simulator;
}).future()();
};
return iPhoneSimulator;
})();
}
createSimulator() {
return new iphone_simulator_xcode_simctl_1.XCodeSimctlSimulator();
}
}
exports.iPhoneSimulator = iPhoneSimulator;
"use strict";
var yargs = require("yargs");
var _ = require("lodash");
var OptionType = (function () {
function OptionType() {
}
OptionType.String = "string";
OptionType.Boolean = "boolean";
return OptionType;
})();
const _ = require("lodash");
class OptionType {
}
OptionType.String = "string";
OptionType.Boolean = "boolean";
var knownOptions = {

@@ -29,5 +26,5 @@ "debug": { type: OptionType.Boolean },

var argv = yargs(process.argv.slice(2)).options(knownOptions).argv;
_.each(_.keys(argv), function (optionName) {
_.each(_.keys(argv), optionName => {
parsed[optionName] = argv[optionName];
});
module.exports = parsed;
"use strict";
var childProcess = require("./child-process");
var errors = require("./errors");
var options = require("./options");
var _ = require("lodash");
var Simctl = (function () {
function Simctl() {
const childProcess = require("./child-process");
const errors = require("./errors");
const options = require("./options");
const _ = require("lodash");
class Simctl {
launch(deviceId, appIdentifier) {
let args = [];
if (options.waitForDebugger) {
args.push("-w");
}
args = args.concat([deviceId, appIdentifier]);
if (options.args) {
let applicationArgs = options.args.trim().split(/\s+/);
_.each(applicationArgs, (arg) => args.push(arg));
}
let result = this.simctlExec("launch", args);
if (options.waitForDebugger) {
console.log(`${appIdentifier}: ${result}`);
}
return result;
}
Simctl.prototype.launch = function (deviceId, appIdentifier) {
var _this = this;
return (function () {
var args = [];
if (options.waitForDebugger) {
args.push("-w");
}
args = args.concat([deviceId, appIdentifier]);
if (options.args) {
var applicationArgs = options.args.trim().split(/\s+/);
_.each(applicationArgs, function (arg) { return args.push(arg); });
}
var result = _this.simctlExec("launch", args).wait();
if (options.waitForDebugger) {
console.log(appIdentifier + ": " + result);
}
return result;
}).future()();
};
Simctl.prototype.install = function (deviceId, applicationPath) {
install(deviceId, applicationPath) {
return this.simctlExec("install", [deviceId, applicationPath]);
};
Simctl.prototype.uninstall = function (deviceId, appIdentifier, opts) {
}
uninstall(deviceId, appIdentifier, opts) {
return this.simctlExec("uninstall", [deviceId, appIdentifier], opts);
};
Simctl.prototype.notifyPost = function (deviceId, notification) {
}
notifyPost(deviceId, notification) {
return this.simctlExec("notify_post", [deviceId, notification]);
};
Simctl.prototype.getAppContainer = function (deviceId, appIdentifier) {
var _this = this;
return (function () {
try {
return _this.simctlExec("get_app_container", [deviceId, appIdentifier]).wait();
}
getAppContainer(deviceId, appIdentifier) {
try {
return this.simctlExec("get_app_container", [deviceId, appIdentifier]);
}
catch (e) {
if (e.message.indexOf("No such file or directory") > -1) {
return null;
}
catch (e) {
if (e.message.indexOf("No such file or directory") > -1) {
return null;
throw e;
}
}
getDevices() {
let rawDevices = this.simctlExec("list", ["devices"]);
let deviceSectionRegex = /-- (iOS) (.+) --(\n .+)*/mg;
let match = deviceSectionRegex.exec(rawDevices);
let matches = [];
while (match !== null) {
matches.push(match);
match = deviceSectionRegex.exec(rawDevices);
}
if (matches.length < 1) {
errors.fail('Could not find device section. ' + match);
}
let devices = [];
for (match of matches) {
let sdk = match[2];
for (let line of match[0].split('\n').slice(1)) {
let lineRegex = /^ ([^\(]+) \(([^\)]+)\) \(([^\)]+)\)( \(([^\)]+)\))*/;
let lineMatch = lineRegex.exec(line);
if (lineMatch === null) {
errors.fail('Could not match line. ' + line);
}
throw e;
}
}).future()();
};
Simctl.prototype.getDevices = function () {
var _this = this;
return (function () {
var rawDevices = _this.simctlExec("list", ["devices"]).wait();
var deviceSectionRegex = /-- (iOS) (.+) --(\n .+)*/mg;
var match = deviceSectionRegex.exec(rawDevices);
var matches = [];
while (match !== null) {
matches.push(match);
match = deviceSectionRegex.exec(rawDevices);
}
if (matches.length < 1) {
errors.fail('Could not find device section. ' + match);
}
var devices = [];
for (var _i = 0; _i < matches.length; _i++) {
match = matches[_i];
var sdk = match[2];
for (var _a = 0, _b = match[0].split('\n').slice(1); _a < _b.length; _a++) {
var line = _b[_a];
var lineRegex = /^ ([^\(]+) \(([^\)]+)\) \(([^\)]+)\)( \(([^\)]+)\))*/;
var lineMatch = lineRegex.exec(line);
if (lineMatch === null) {
errors.fail('Could not match line. ' + line);
}
var available = lineMatch[4];
if (available === null || available === undefined) {
devices.push({
name: lineMatch[1],
id: lineMatch[2],
fullId: "com.apple.CoreSimulator.SimDeviceType." + lineMatch[1],
runtimeVersion: sdk,
state: lineMatch[3]
});
}
let available = lineMatch[4];
if (available === null || available === undefined) {
devices.push({
name: lineMatch[1],
id: lineMatch[2],
fullId: "com.apple.CoreSimulator.SimDeviceType." + lineMatch[1],
runtimeVersion: sdk,
state: lineMatch[3]
});
}
}
return devices;
}).future()();
};
Simctl.prototype.simctlExec = function (command, args, opts) {
args = ["simctl", command].concat(args);
return childProcess.spawn("xcrun", args, opts);
};
return Simctl;
})();
}
return devices;
}
simctlExec(command, args, opts) {
let fullCommand = (["xcrun", "simctl", command].concat(args)).join(" ");
return childProcess.execSync(fullCommand, opts).toString().trim();
}
}
exports.Simctl = Simctl;
"use strict";
var Fiber = require("fibers");
function stringify(arr, delimiter) {

@@ -8,7 +7,14 @@ delimiter = delimiter || ", ";

exports.stringify = stringify;
function getCurrentEpochTime() {
let dateTime = new Date();
return dateTime.getTime();
}
exports.getCurrentEpochTime = getCurrentEpochTime;
function sleep(ms) {
var fiber = Fiber.current;
setTimeout(function () { return fiber.run(); }, ms);
Fiber.yield();
let startTime = getCurrentEpochTime();
let currentTime = getCurrentEpochTime();
while ((currentTime - startTime) < ms) {
currentTime = getCurrentEpochTime();
}
}
exports.sleep = sleep;
"use strict";
var childProcess = require("./child-process");
const childProcess = require("./child-process");
function getPathFromXcodeSelect() {
return childProcess.spawn("xcode-select", ["-print-path"]);
return childProcess.execSync("xcode-select -print-path").toString().trim();
}
exports.getPathFromXcodeSelect = getPathFromXcodeSelect;
function getXcodeVersionData() {
return (function () {
var rawData = childProcess.spawn("xcodebuild", ["-version"]).wait();
var lines = rawData.split("\n");
var parts = lines[0].split(" ")[1].split(".");
return {
major: parts[0],
minor: parts[1],
build: lines[1].split("Build version ")[1]
};
}).future()();
let rawData = childProcess.execSync("xcodebuild -version");
let lines = rawData.split("\n");
let parts = lines[0].split(" ")[1].split(".");
return {
major: parts[0],
minor: parts[1],
build: lines[1].split("Build version ")[1]
};
}
exports.getXcodeVersionData = getXcodeVersionData;
{
"name": "ios-sim-portable",
"version": "1.6.1",
"version": "2.0.0",
"description": "",
"main": "./lib/ios-sim.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"postinstall": "node postinstall.js"
"test": "echo \"Error: no test specified\" && exit 1"
},

@@ -29,7 +28,5 @@ "bin": {

"dependencies": {
"bplist-parser": "0.1.0",
"bplist-parser": "https://github.com/telerik/node-bplist-parser/tarball/master",
"colors": "0.6.2",
"fibers": "https://github.com/icenium/node-fibers/tarball/v1.0.15.0",
"lodash": "3.2.0",
"nodobjc": "https://github.com/telerik/NodObjC/tarball/v2.0.0.4",
"osenv": "0.1.3",

@@ -45,3 +42,3 @@ "plist": "1.1.0",

"grunt-ts": "5.5.1",
"typescript": "1.7.5"
"typescript": "2.1.4"
},

@@ -48,0 +45,0 @@ "engines": {

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc