Skip to content

An ADB wrapper made in node js. For mobile debugging

License

Notifications You must be signed in to change notification settings

amiralam0/adb-wrapper-node-js

 
 

Repository files navigation

Adb-Wrapper

An awesome ADB wrapper made in node js to use adb just with functions.
· Report Bug · Request Feature

Table of Contents
  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License
  6. Contact

About The Project

The adb wrapper provides a flexibal API to execute adb commands.
A user can also pass the custom the adb path to it.

(back to top)

Getting Started

If you dont have ADB installed in your system, dont worry. It has inbuilt adb, you could also provide a path for adb explicity, which the module will use.

Prerequisites

Node js and an initialized npm folder

  • npm
    npm install adb-wrapper

See the open issues for a full list of proposed features (and known issues).

(back to top)

Usage

After installation of the module into your project, you can take this simple example.

import ADB from "adb-wrapper";

async function main() {
  var getAdbInstalled = await ADB.isAdbInstalled();

  if (!getAdbInstalled) return console.log("Adb is not installed");

  var deviceList = await ADB.deviceList();

  console.log(`Connected Devices ${JSON.stringify(deviceList)}`);
}

main();

There will be more functions in upcoming days as we are actively developing it. Watch it to get notified whenever we add something new to it. 😉

(back to top)

Methods

Here are the list of methods you can use.

  • deviceList()
    Returns: { type: string, udid: string, port: string} Returns Object of all detected devices by adb.

  • setCurrentActiveDevice()
    Prams: device (device udid)
    set the current active device

  • isAdbInstalled()
    Returns: boolean
    detect if adb is installed or not

  • setAdbExplicitPath()
    Params: path (folder path of the adb)
    if the adb is not installed, you can manually download it and provide the path of the folder where adb.exe exsists

  • killServer()
    kill the adb server

  • startServer()
    start the adb server

  • tcpip()
    Prams: port (port on which to start the adb server listening to)
    adb listen to a port

  • connectRemote()
    Params: {ip( of the remote host), port (of remort host)} (folder path of the adb)
    connect to a device on a remote host

  • disconnectRemote()
    Params: {ip( of the remote host), port (of remort host)} (folder path of the adb)
    disconnect to a device on a remote host

    Please set the current active device to which the command will executed, some function wont work. Do it by calling setCurrentActiveDevice() and providing the udid of the device.
    You can get the devices udid by calling the function deviceList()

  • installApp()
    Params: apkPath (path of the apk)
    Install the app to the current active android device

  • uninstallApp()
    Params: packageId (the package id of the app to uninstall)
    uninstall the app given by the package id

  • execShellCmd()
    Params: shellCmd (shell command) note: dont include shell in it
    its equivalent to adb shell. you can execute the shell commands using it

  • getCurrentOpendedActivity()
    Returns: packageInfo (of the current Activity Openned)
    it will return the info of the current openned activity, including the package id of the app.

Contributing

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

(back to top)

License

Distributed under the MIT License. See LICENSE.txt for more information.

(back to top)

Contact

Author Name - @amir-alam-44378416b - sharpprogrammer2018@gmail.com

Project Link: https://github.com/MrSharpp/adb-wrapper-node-js

(back to top)

About

An ADB wrapper made in node js. For mobile debugging

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 89.1%
  • JavaScript 9.5%
  • Shell 1.4%