"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getNativeTargets = exports.findNativeRun = exports.checkNativeRun = exports.runNativeRun = exports.createNativeRunListArgs = exports.createNativeRunArgs = exports.SUPPORTED_PLATFORMS = void 0; const utils_process_1 = require("@ionic/utils-process"); const utils_subprocess_1 = require("@ionic/utils-subprocess"); const color_1 = require("./color"); const errors_1 = require("./errors"); const logger_1 = require("./utils/logger"); const npm_1 = require("./utils/npm"); exports.SUPPORTED_PLATFORMS = ['ios', 'android']; function createNativeRunArgs({ packagePath, platform, forwardedPorts = [] }, options) { const opts = [platform, '--app', packagePath]; const target = options['target'] ? String(options['target']) : undefined; if (target) { opts.push('--target', target); } else if (options['emulator']) { opts.push('--virtual'); } else if (options['device']) { opts.push('--device'); } if (options['connect']) { opts.push('--connect'); } for (const port of forwardedPorts) { opts.push('--forward', `${port}:${port}`); } if (options['json']) { opts.push('--json'); } if (options['verbose']) { opts.push('--verbose'); } return opts; } exports.createNativeRunArgs = createNativeRunArgs; function createNativeRunListArgs(inputs, options) { const args = []; if (inputs[0]) { args.push(inputs[0]); } args.push('--list'); if (options['json']) { args.push('--json'); } if (options['device']) { args.push('--device'); } if (options['emulator']) { args.push('--virtual'); } if (options['json']) { args.push('--json'); } return args; } exports.createNativeRunListArgs = createNativeRunListArgs; async function runNativeRun({ config, log, shell }, args, options = {}) { const connect = args.includes('--connect'); const stream = logger_1.createPrefixedWriteStream(log, color_1.weak(`[native-run]`)); try { await shell.run('native-run', args, { showCommand: !args.includes('--json'), fatalOnNotFound: false, stream, ...options }); } catch (e) { if (e instanceof utils_subprocess_1.SubprocessError && e.code === utils_subprocess_1.ERROR_COMMAND_NOT_FOUND) { throw createNativeRunNotFoundError(config.get('npmClient')); } throw e; } // If we connect the `native-run` process to the running app, then we // should also connect the Ionic CLI with the running `native-run` process. // This will exit the Ionic CLI when `native-run` exits. if (connect) { utils_process_1.processExit(0); } } exports.runNativeRun = runNativeRun; async function checkNativeRun({ config }) { const p = await findNativeRun(); if (!p) { throw await createNativeRunNotFoundError(config.get('npmClient')); } } exports.checkNativeRun = checkNativeRun; async function findNativeRun() { try { return await utils_subprocess_1.which('native-run'); } catch (e) { if (e.code !== 'ENOENT') { throw e; } } } exports.findNativeRun = findNativeRun; async function createNativeRunNotFoundError(npmClient) { const installArgs = await npm_1.pkgManagerArgs(npmClient, { command: 'install', pkg: 'native-run', global: true }); return new errors_1.FatalException(`${color_1.input('native-run')} was not found on your PATH. Please install it globally:\n` + `${color_1.input(installArgs.join(' '))}\n`); } async function getNativeTargets({ log, shell }, platform) { try { const proc = await shell.createSubprocess('native-run', [platform, '--list', '--json']); const output = await proc.output(); return JSON.parse(output); } catch (e) { if (e instanceof utils_subprocess_1.SubprocessError && e.code === utils_subprocess_1.ERROR_NON_ZERO_EXIT) { const output = e.output ? JSON.parse(e.output) : {}; throw new errors_1.FatalException(`Error while getting native targets for ${color_1.input(platform)}: ${output.error || output.code}\n` + (platform === 'android' && output.code === 'ERR_UNSUITABLE_API_INSTALLATION' ? (`\n${color_1.input('native-run')} needs a fully installed SDK Platform to run your app.\n` + `- Run ${color_1.input('native-run android --sdk-info')} to see missing packages for each API level.\n` + `- Install missing packages in Android Studio by opening the SDK manager.\n`) : '') + `\nThis error occurred while using ${color_1.input('native-run')}. You can try running this command with ${color_1.input('--no-native-run')}, which will revert to using Cordova.\n`); } log.warn(`Error while getting native targets for ${color_1.input(platform)}:\n${e.stack ? e.stack : e}`); } return { devices: [], virtualDevices: [] }; } exports.getNativeTargets = getNativeTargets;
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
doctor | Folder | 0755 |
|
|
integrations | Folder | 0755 |
|
|
oauth | Folder | 0755 |
|
|
project | Folder | 0755 |
|
|
utils | Folder | 0755 |
|
|
app.d.ts | File | 1.15 KB | 0644 |
|
app.js | File | 2.5 KB | 0644 |
|
build.d.ts | File | 3.43 KB | 0644 |
|
build.js | File | 8.51 KB | 0644 |
|
color.d.ts | File | 484 B | 0644 |
|
color.js | File | 768 B | 0644 |
|
command.d.ts | File | 924 B | 0644 |
|
command.js | File | 5.47 KB | 0644 |
|
config.d.ts | File | 843 B | 0644 |
|
config.js | File | 3.83 KB | 0644 |
|
cordova-res.d.ts | File | 1.07 KB | 0644 |
|
cordova-res.js | File | 2.62 KB | 0644 |
|
diff.d.ts | File | 100 B | 0644 |
|
diff.js | File | 709 B | 0644 |
|
environment.d.ts | File | 1004 B | 0644 |
|
environment.js | File | 516 B | 0644 |
|
errors.d.ts | File | 891 B | 0644 |
|
errors.js | File | 1.77 KB | 0644 |
|
events.d.ts | File | 240 B | 0644 |
|
events.js | File | 498 B | 0644 |
|
executor.d.ts | File | 1 KB | 0644 |
|
executor.js | File | 3.7 KB | 0644 |
|
generate.d.ts | File | 923 B | 0644 |
|
generate.js | File | 351 B | 0644 |
|
git.d.ts | File | 747 B | 0644 |
|
git.js | File | 1.66 KB | 0644 |
|
help.d.ts | File | 2.4 KB | 0644 |
|
help.js | File | 3.66 KB | 0644 |
|
helper.d.ts | File | 252 B | 0644 |
|
helper.js | File | 654 B | 0644 |
|
hooks.d.ts | File | 841 B | 0644 |
|
hooks.js | File | 4.72 KB | 0644 |
|
http.d.ts | File | 2.62 KB | 0644 |
|
http.js | File | 7.56 KB | 0644 |
|
index.d.ts | File | 226 B | 0644 |
|
index.js | File | 6.09 KB | 0644 |
|
ionitron.d.ts | File | 148 B | 0644 |
|
ionitron.js | File | 4.72 KB | 0644 |
|
namespace.d.ts | File | 854 B | 0644 |
|
namespace.js | File | 686 B | 0644 |
|
native-run.d.ts | File | 1.5 KB | 0644 |
|
native-run.js | File | 4.98 KB | 0644 |
|
open.d.ts | File | 164 B | 0644 |
|
open.js | File | 507 B | 0644 |
|
prompts.d.ts | File | 402 B | 0644 |
|
prompts.js | File | 716 B | 0644 |
|
security.d.ts | File | 511 B | 0644 |
|
security.js | File | 785 B | 0644 |
|
serve.d.ts | File | 5.79 KB | 0644 |
|
serve.js | File | 22.4 KB | 0644 |
|
session.d.ts | File | 921 B | 0644 |
|
session.js | File | 7.82 KB | 0644 |
|
shell.d.ts | File | 1.95 KB | 0644 |
|
shell.js | File | 8.41 KB | 0644 |
|
snapshot.d.ts | File | 765 B | 0644 |
|
snapshot.js | File | 1.13 KB | 0644 |
|
ssh-config.d.ts | File | 646 B | 0644 |
|
ssh-config.js | File | 3.04 KB | 0644 |
|
ssh.d.ts | File | 1.67 KB | 0644 |
|
ssh.js | File | 3.53 KB | 0644 |
|
start.d.ts | File | 1.34 KB | 0644 |
|
start.js | File | 12.1 KB | 0644 |
|
telemetry.d.ts | File | 972 B | 0644 |
|
telemetry.js | File | 3.59 KB | 0644 |
|
updates.d.ts | File | 1.01 KB | 0644 |
|
updates.js | File | 3.82 KB | 0644 |
|
user.d.ts | File | 865 B | 0644 |
|
user.js | File | 2.37 KB | 0644 |
|