diff --git a/lib/commands/certificate.js b/lib/commands/certificate.js index a5e7dbdd3..61cc41013 100644 --- a/lib/commands/certificate.js +++ b/lib/commands/certificate.js @@ -445,7 +445,9 @@ export default { * is available on the server machine. * * @param {string} name - Name of certificate to remove - * @returns {Promise} Returns status acknowledgment if successfully removed certificate or 'None' + * @returns {Promise} Returns status acknowledgment status if + * tht certificate is successfully removed or 'None' (basically just + * forwards the original pyidevice output) * @throws {Error} If attempting to remote certificates for simulated device or if py-ios-device * is not installed * @group Real Device Only diff --git a/lib/py-ios-device-client.js b/lib/py-ios-device-client.js index 8bd6a9a5d..454c6ddb0 100644 --- a/lib/py-ios-device-client.js +++ b/lib/py-ios-device-client.js @@ -8,11 +8,18 @@ import path from 'path'; const BINARY_NAME = 'pyidevice'; class Pyidevice { + /** + * @param {string} udid + */ constructor (udid) { this.udid = udid; this.binaryPath = null; } + /** + * @param {boolean} isStrict + * @return {Promise} + */ async assertExists (isStrict = true) { if (this.binaryPath) { return true; @@ -31,6 +38,19 @@ class Pyidevice { } } + /** + * @typedef {Object} ExecuteOptions + * @property {string} cwd + * @property {string} format [json] + * @property {boolean} logStdout [false] + * @property {boolean} asynchronous [false] + */ + + /** + * @param {string[]} args + * @param {Partial} opts + * @return {Promise} + */ async execute (args, opts = {}) { await this.assertExists(); const { @@ -62,6 +82,9 @@ class Pyidevice { } } + /** + * @return {Promise} + */ async listProfiles () { const {stdout} = /** @type {import('teen_process').TeenProcessExecResult} */(await this.execute(['profiles', 'list'])); return JSON.parse(stdout); @@ -96,15 +119,29 @@ class Pyidevice { } } + /** + * @param {string} name + * @returns {Promise} + */ async removeProfile (name) { - await this.execute(['profiles', 'remove', '--name', name], {logStdout: true}); + return /** @type {import('teen_process').TeenProcessExecResult} */ (await this.execute([ + 'profiles', 'remove', '--name', name + ], {logStdout: true})).stdout; } + /** + * @returns {Promise} + */ async listCrashes () { const {stdout} = /** @type {import('teen_process').TeenProcessExecResult} */(await this.execute(['crash', 'list'])); return JSON.parse(stdout.replace(/'/g, '"')).filter((x) => !['.', '..'].includes(x)); } + /** + * @param {string} name + * @param {string} dstFolder + * @returns {Promise} + */ async exportCrash (name, dstFolder) { await this.execute(['crash', 'export', '--name', name], { logStdout: true, @@ -112,7 +149,9 @@ class Pyidevice { cwd: dstFolder }); } - + /** + * @param {string} dstFile + */ async collectPcap (dstFile) { return await this.execute(['pcapd', dstFile], { format: null,