-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: ivnert the reverse port CLI option * feat: run adb reverse by default * refactor: log adb reverse only in debug, more verbose logging * feat: add adb reverse interaction * fix: run adb reverse on watchRun when using rspack * test: align setupInteractions tests * refactor: use lowercase adb * chore: add changeset * refactor: run when bundling for Android * refactor: undo cli flag changes
- Loading branch information
Showing
7 changed files
with
96 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@callstack/repack": minor | ||
--- | ||
|
||
Added `adb reverse` interaction & `adb reverse` command is now run by default when bundling for Android |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,35 @@ | ||
import execa from 'execa'; | ||
import type { Logger } from '../../types'; | ||
|
||
export async function runAdbReverse(port: number, logger: Logger = console) { | ||
interface RunAdbReverseParams { | ||
port: number; | ||
verbose?: boolean; | ||
logger?: Logger; | ||
} | ||
|
||
export async function runAdbReverse({ | ||
port, | ||
verbose = false, | ||
logger = console, | ||
}: RunAdbReverseParams) { | ||
const adbPath = process.env.ANDROID_HOME | ||
? `${process.env.ANDROID_HOME}/platform-tools/adb` | ||
: 'adb'; | ||
const command = `${adbPath} reverse tcp:${port} tcp:${port}`; | ||
const info = JSON.stringify({ port, adbPath, command }); | ||
|
||
try { | ||
await execa.command(command); | ||
logger.info(`Successfully run: ${command}`); | ||
if (verbose) { | ||
logger.info('adb reverse success'); | ||
} | ||
logger.debug(`adb reverse success: ${info}`); | ||
} catch (error) { | ||
// Get just the error message | ||
const message = | ||
(error as Error).message.split('error:')[1] || (error as Error).message; | ||
logger.warn(`Failed to run: ${command} - ${message.trim()}`); | ||
if (verbose) { | ||
logger.warn(`adb reverse failed: "${message.trim()}"`); | ||
} | ||
logger.debug(`adb reverse failed: "${message.trim()}" ${info}`); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters