forked from olcxjas-softworks/LarpixClient
fix gitignore again
This commit is contained in:
parent
ce5a1e330b
commit
5da5c2afe2
3329 changed files with 364540 additions and 3 deletions
60
electron/node_modules/native-run/dist/ios/utils/app.js
generated
vendored
Normal file
60
electron/node_modules/native-run/dist/ios/utils/app.js
generated
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.unzipIPA = exports.getBundleId = void 0;
|
||||
const utils_fs_1 = require("@ionic/utils-fs");
|
||||
const Debug = require("debug");
|
||||
const fs_1 = require("fs");
|
||||
const path = require("path");
|
||||
const errors_1 = require("../../errors");
|
||||
const process_1 = require("../../utils/process");
|
||||
const unzip_1 = require("../../utils/unzip");
|
||||
const debug = Debug('native-run:ios:utils:app');
|
||||
// TODO: cross platform? Use plist/bplist
|
||||
async function getBundleId(appPath) {
|
||||
const plistPath = path.resolve(appPath, 'Info.plist');
|
||||
try {
|
||||
const { stdout } = await (0, process_1.execFile)('/usr/libexec/PlistBuddy', ['-c', 'Print :CFBundleIdentifier', plistPath], {
|
||||
encoding: 'utf8',
|
||||
});
|
||||
if (stdout) {
|
||||
return stdout.trim();
|
||||
}
|
||||
}
|
||||
catch {
|
||||
// ignore
|
||||
}
|
||||
throw new errors_1.Exception('Unable to get app bundle identifier');
|
||||
}
|
||||
exports.getBundleId = getBundleId;
|
||||
async function unzipIPA(ipaPath, destPath) {
|
||||
let error;
|
||||
let appPath = '';
|
||||
await (0, unzip_1.unzip)(ipaPath, async (entry, zipfile, openReadStream) => {
|
||||
debug(`Unzip: ${entry.fileName}`);
|
||||
const dest = path.join(destPath, entry.fileName);
|
||||
if (entry.fileName.endsWith('/')) {
|
||||
await (0, utils_fs_1.mkdirp)(dest);
|
||||
if (entry.fileName.endsWith('.app/')) {
|
||||
appPath = entry.fileName;
|
||||
}
|
||||
zipfile.readEntry();
|
||||
}
|
||||
else {
|
||||
await (0, utils_fs_1.mkdirp)(path.dirname(dest));
|
||||
const readStream = await openReadStream(entry);
|
||||
readStream.on('error', (err) => (error = err));
|
||||
readStream.on('end', () => {
|
||||
zipfile.readEntry();
|
||||
});
|
||||
readStream.pipe((0, fs_1.createWriteStream)(dest));
|
||||
}
|
||||
});
|
||||
if (error) {
|
||||
throw error;
|
||||
}
|
||||
if (!appPath) {
|
||||
throw new errors_1.Exception('Unable to determine .app directory from .ipa');
|
||||
}
|
||||
return appPath;
|
||||
}
|
||||
exports.unzipIPA = unzipIPA;
|
||||
141
electron/node_modules/native-run/dist/ios/utils/device.js
generated
vendored
Normal file
141
electron/node_modules/native-run/dist/ios/utils/device.js
generated
vendored
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.runOnDevice = exports.getConnectedDevices = void 0;
|
||||
const child_process_1 = require("child_process");
|
||||
const Debug = require("debug");
|
||||
const fs_1 = require("fs");
|
||||
const path = require("path");
|
||||
const errors_1 = require("../../errors");
|
||||
const process_1 = require("../../utils/process");
|
||||
const lib_1 = require("../lib");
|
||||
const xcode_1 = require("./xcode");
|
||||
const debug = Debug('native-run:ios:utils:device');
|
||||
async function getConnectedDevices() {
|
||||
const usbmuxClient = new lib_1.UsbmuxdClient(lib_1.UsbmuxdClient.connectUsbmuxdSocket());
|
||||
const usbmuxDevices = await usbmuxClient.getDevices();
|
||||
usbmuxClient.socket.end();
|
||||
return Promise.all(usbmuxDevices.map(async (d) => {
|
||||
const socket = await new lib_1.UsbmuxdClient(lib_1.UsbmuxdClient.connectUsbmuxdSocket()).connect(d, 62078);
|
||||
const device = await new lib_1.LockdowndClient(socket).getAllValues();
|
||||
socket.end();
|
||||
// For network-connected devices, UniqueDeviceID may not be present in lockdownd response
|
||||
// Use SerialNumber from usbmuxd device info as fallback (they are the same value)
|
||||
if (!device.UniqueDeviceID && d.Properties && d.Properties.SerialNumber) {
|
||||
device.UniqueDeviceID = d.Properties.SerialNumber;
|
||||
debug(`Using SerialNumber as UniqueDeviceID for network device: ${device.UniqueDeviceID}`);
|
||||
}
|
||||
return device;
|
||||
}));
|
||||
}
|
||||
exports.getConnectedDevices = getConnectedDevices;
|
||||
async function runOnDevice(udid, appPath, bundleId, waitForApp) {
|
||||
const clientManager = await lib_1.ClientManager.create(udid);
|
||||
try {
|
||||
await mountDeveloperDiskImage(clientManager);
|
||||
const packageName = path.basename(appPath);
|
||||
const destPackagePath = path.join('PublicStaging', packageName);
|
||||
await uploadApp(clientManager, appPath, destPackagePath);
|
||||
const installer = await clientManager.getInstallationProxyClient();
|
||||
await installer.installApp(destPackagePath, bundleId);
|
||||
const { [bundleId]: appInfo } = await installer.lookupApp([bundleId]);
|
||||
// launch fails with EBusy or ENotFound if you try to launch immediately after install
|
||||
await (0, process_1.wait)(200);
|
||||
try {
|
||||
const debugServerClient = await launchApp(clientManager, appInfo);
|
||||
if (waitForApp) {
|
||||
(0, process_1.onBeforeExit)(async () => {
|
||||
// causes continue() to return
|
||||
debugServerClient.halt();
|
||||
// give continue() time to return response
|
||||
await (0, process_1.wait)(64);
|
||||
});
|
||||
debug(`Waiting for app to close...\n`);
|
||||
const result = await debugServerClient.continue();
|
||||
// TODO: I have no idea what this packet means yet (successful close?)
|
||||
// if not a close (ie, most likely due to halt from onBeforeExit), then kill the app
|
||||
if (result !== 'W00') {
|
||||
await debugServerClient.kill();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch {
|
||||
// if launching app throws, try with devicectl, but requires Xcode 15
|
||||
const [xcodeVersion] = (0, xcode_1.getXcodeVersionInfo)();
|
||||
const xcodeMajorVersion = Number(xcodeVersion.split('.')[0]);
|
||||
if (xcodeMajorVersion >= 15) {
|
||||
const launchResult = (0, child_process_1.spawn)('xcrun', ['devicectl', 'device', 'process', 'launch', '--device', udid, bundleId]);
|
||||
return new Promise((resolve, reject) => {
|
||||
launchResult.on('close', (code) => {
|
||||
if (code === 0) {
|
||||
resolve();
|
||||
}
|
||||
else {
|
||||
reject(new errors_1.Exception(`There was an error launching app on device`));
|
||||
}
|
||||
});
|
||||
launchResult.on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
});
|
||||
}
|
||||
else {
|
||||
throw new errors_1.Exception(`running on iOS 17 devices requires Xcode 15 and later`);
|
||||
}
|
||||
}
|
||||
}
|
||||
finally {
|
||||
clientManager.end();
|
||||
}
|
||||
}
|
||||
exports.runOnDevice = runOnDevice;
|
||||
async function mountDeveloperDiskImage(clientManager) {
|
||||
const imageMounter = await clientManager.getMobileImageMounterClient();
|
||||
// Check if already mounted. If not, mount.
|
||||
if (!(await imageMounter.lookupImage()).ImageSignature) {
|
||||
// verify DeveloperDiskImage exists (TODO: how does this work on Windows/Linux?)
|
||||
// TODO: if windows/linux, download?
|
||||
const version = await (await clientManager.getLockdowndClient()).getValue('ProductVersion');
|
||||
const developerDiskImagePath = await (0, xcode_1.getDeveloperDiskImagePath)(version);
|
||||
const developerDiskImageSig = (0, fs_1.readFileSync)(`${developerDiskImagePath}.signature`);
|
||||
await imageMounter.uploadImage(developerDiskImagePath, developerDiskImageSig);
|
||||
await imageMounter.mountImage(developerDiskImagePath, developerDiskImageSig);
|
||||
}
|
||||
}
|
||||
async function uploadApp(clientManager, srcPath, destinationPath) {
|
||||
const afcClient = await clientManager.getAFCClient();
|
||||
try {
|
||||
await afcClient.getFileInfo('PublicStaging');
|
||||
}
|
||||
catch (err) {
|
||||
if (err instanceof lib_1.AFCError && err.status === lib_1.AFC_STATUS.OBJECT_NOT_FOUND) {
|
||||
await afcClient.makeDirectory('PublicStaging');
|
||||
}
|
||||
else {
|
||||
throw err;
|
||||
}
|
||||
}
|
||||
await afcClient.uploadDirectory(srcPath, destinationPath);
|
||||
}
|
||||
async function launchApp(clientManager, appInfo) {
|
||||
let tries = 0;
|
||||
while (tries < 3) {
|
||||
const debugServerClient = await clientManager.getDebugserverClient();
|
||||
await debugServerClient.setMaxPacketSize(1024);
|
||||
await debugServerClient.setWorkingDir(appInfo.Container);
|
||||
await debugServerClient.launchApp(appInfo.Path, appInfo.CFBundleExecutable);
|
||||
const result = await debugServerClient.checkLaunchSuccess();
|
||||
if (result === 'OK') {
|
||||
return debugServerClient;
|
||||
}
|
||||
else if (result === 'EBusy' || result === 'ENotFound') {
|
||||
debug('Device busy or app not found, trying to launch again in .5s...');
|
||||
tries++;
|
||||
debugServerClient.socket.end();
|
||||
await (0, process_1.wait)(500);
|
||||
}
|
||||
else {
|
||||
throw new errors_1.Exception(`There was an error launching app: ${result}`);
|
||||
}
|
||||
}
|
||||
throw new errors_1.Exception('Unable to launch app, number of tries exceeded');
|
||||
}
|
||||
90
electron/node_modules/native-run/dist/ios/utils/simulator.js
generated
vendored
Normal file
90
electron/node_modules/native-run/dist/ios/utils/simulator.js
generated
vendored
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.runOnSimulator = exports.getSimulators = void 0;
|
||||
const child_process_1 = require("child_process"); // TODO: need cross-spawn for windows?
|
||||
const Debug = require("debug");
|
||||
const errors_1 = require("../../errors");
|
||||
const log_1 = require("../../utils/log");
|
||||
const process_1 = require("../../utils/process");
|
||||
const xcode_1 = require("./xcode");
|
||||
const debug = Debug('native-run:ios:utils:simulator');
|
||||
async function getSimulators() {
|
||||
const simctl = (0, child_process_1.spawnSync)('xcrun', ['simctl', 'list', '--json'], {
|
||||
encoding: 'utf8',
|
||||
});
|
||||
if (simctl.status) {
|
||||
throw new errors_1.Exception(`Unable to retrieve simulator list: ${simctl.stderr}`);
|
||||
}
|
||||
try {
|
||||
const output = JSON.parse(simctl.stdout);
|
||||
return output.runtimes
|
||||
.filter((runtime) => runtime.name.indexOf('watch') === -1 && runtime.name.indexOf('tv') === -1)
|
||||
.map((runtime) => (output.devices[runtime.identifier] || output.devices[runtime.name])
|
||||
.filter((device) => device.isAvailable)
|
||||
.map((device) => ({ ...device, runtime })))
|
||||
.reduce((prev, next) => prev.concat(next)) // flatten
|
||||
.sort((a, b) => (a.name < b.name ? -1 : 1));
|
||||
}
|
||||
catch (err) {
|
||||
throw new errors_1.Exception(`Unable to retrieve simulator list: ${err.message}`);
|
||||
}
|
||||
}
|
||||
exports.getSimulators = getSimulators;
|
||||
async function runOnSimulator(udid, appPath, bundleId, waitForApp) {
|
||||
debug(`Booting simulator ${udid}`);
|
||||
const bootResult = (0, child_process_1.spawnSync)('xcrun', ['simctl', 'boot', udid], {
|
||||
encoding: 'utf8',
|
||||
});
|
||||
// TODO: is there a better way to check this?
|
||||
if (bootResult.status && !bootResult.stderr.includes('Unable to boot device in current state: Booted')) {
|
||||
throw new errors_1.Exception(`There was an error booting simulator: ${bootResult.stderr}`);
|
||||
}
|
||||
debug(`Installing ${appPath} on ${udid}`);
|
||||
const installResult = (0, child_process_1.spawnSync)('xcrun', ['simctl', 'install', udid, appPath], { encoding: 'utf8' });
|
||||
if (installResult.status) {
|
||||
throw new errors_1.Exception(`There was an error installing app on simulator: ${installResult.stderr}`);
|
||||
}
|
||||
const xCodePath = await (0, xcode_1.getXCodePath)();
|
||||
debug(`Running simulator ${udid}`);
|
||||
const openResult = (0, child_process_1.spawnSync)('open', [`${xCodePath}/Applications/Simulator.app`, '--args', '-CurrentDeviceUDID', udid], { encoding: 'utf8' });
|
||||
if (openResult.status) {
|
||||
throw new errors_1.Exception(`There was an error opening simulator: ${openResult.stderr}`);
|
||||
}
|
||||
debug(`Launching ${appPath} on ${udid}`);
|
||||
const launchResult = (0, child_process_1.spawnSync)('xcrun', ['simctl', 'launch', udid, bundleId], { encoding: 'utf8' });
|
||||
if (launchResult.status) {
|
||||
throw new errors_1.Exception(`There was an error launching app on simulator: ${launchResult.stderr}`);
|
||||
}
|
||||
if (waitForApp) {
|
||||
(0, process_1.onBeforeExit)(async () => {
|
||||
const terminateResult = (0, child_process_1.spawnSync)('xcrun', ['simctl', 'terminate', udid, bundleId], { encoding: 'utf8' });
|
||||
if (terminateResult.status) {
|
||||
debug('Unable to terminate app on simulator');
|
||||
}
|
||||
});
|
||||
(0, log_1.log)(`Waiting for app to close...\n`);
|
||||
await waitForSimulatorClose(udid, bundleId);
|
||||
}
|
||||
}
|
||||
exports.runOnSimulator = runOnSimulator;
|
||||
async function waitForSimulatorClose(udid, bundleId) {
|
||||
return new Promise((resolve) => {
|
||||
// poll service list for bundle id
|
||||
const interval = setInterval(async () => {
|
||||
try {
|
||||
const data = (0, child_process_1.spawnSync)('xcrun', ['simctl', 'spawn', udid, 'launchctl', 'list'], { encoding: 'utf8' });
|
||||
// if bundle id isn't in list, app isn't running
|
||||
if (data.stdout.indexOf(bundleId) === -1) {
|
||||
clearInterval(interval);
|
||||
resolve();
|
||||
}
|
||||
}
|
||||
catch (e) {
|
||||
debug('Error received from launchctl: %O', e);
|
||||
debug('App %s no longer found in process list for %s', bundleId, udid);
|
||||
clearInterval(interval);
|
||||
resolve();
|
||||
}
|
||||
}, 500);
|
||||
});
|
||||
}
|
||||
54
electron/node_modules/native-run/dist/ios/utils/xcode.js
generated
vendored
Normal file
54
electron/node_modules/native-run/dist/ios/utils/xcode.js
generated
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.getDeveloperDiskImagePath = exports.getXCodePath = exports.getXcodeVersionInfo = void 0;
|
||||
const utils_fs_1 = require("@ionic/utils-fs");
|
||||
const child_process_1 = require("child_process");
|
||||
const errors_1 = require("../../errors");
|
||||
const process_1 = require("../../utils/process");
|
||||
function getXcodeVersionInfo() {
|
||||
const xcodeVersionInfo = (0, child_process_1.spawnSync)('xcodebuild', ['-version'], {
|
||||
encoding: 'utf8',
|
||||
});
|
||||
if (xcodeVersionInfo.error) {
|
||||
throw xcodeVersionInfo.error;
|
||||
}
|
||||
try {
|
||||
const trimmed = xcodeVersionInfo.stdout.trim().split('\n');
|
||||
return ['Xcode ', 'Build version'].map((s, i) => trimmed[i].replace(s, ''));
|
||||
}
|
||||
catch (error) {
|
||||
throw new errors_1.Exception(`There was an error trying to retrieve the Xcode version: ${xcodeVersionInfo.stderr}`);
|
||||
}
|
||||
}
|
||||
exports.getXcodeVersionInfo = getXcodeVersionInfo;
|
||||
async function getXCodePath() {
|
||||
try {
|
||||
const { stdout } = await (0, process_1.execFile)('xcode-select', ['-p'], {
|
||||
encoding: 'utf8',
|
||||
});
|
||||
if (stdout) {
|
||||
return stdout.trim();
|
||||
}
|
||||
}
|
||||
catch {
|
||||
// ignore
|
||||
}
|
||||
throw new errors_1.Exception('Unable to get Xcode location. Is Xcode installed?');
|
||||
}
|
||||
exports.getXCodePath = getXCodePath;
|
||||
async function getDeveloperDiskImagePath(version) {
|
||||
const xCodePath = await getXCodePath();
|
||||
const versionDirs = await (0, utils_fs_1.readdir)(`${xCodePath}/Platforms/iPhoneOS.platform/DeviceSupport/`);
|
||||
const versionPrefix = version.match(/\d+\.\d+/);
|
||||
if (versionPrefix === null) {
|
||||
throw new errors_1.Exception(`Invalid iOS version: ${version}`);
|
||||
}
|
||||
// Can look like "11.2 (15C107)"
|
||||
for (const dir of versionDirs) {
|
||||
if (dir.includes(versionPrefix[0])) {
|
||||
return `${xCodePath}/Platforms/iPhoneOS.platform/DeviceSupport/${dir}/DeveloperDiskImage.dmg`;
|
||||
}
|
||||
}
|
||||
throw new errors_1.Exception(`Unable to find Developer Disk Image path for SDK ${version}. Do you have the right version of Xcode?`);
|
||||
}
|
||||
exports.getDeveloperDiskImagePath = getDeveloperDiskImagePath;
|
||||
Loading…
Add table
Add a link
Reference in a new issue