npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

adb-batch-manager

v2.0.1

Published

Batch management tool for Android devices using ADB

Readme

ADB Batch Manager

Android设备批量管理工具,支持批量安装、卸载、启动应用等操作。

特性

  • 🔄 批量连接多个Android设备
  • 📱 应用批量安装、卸载、启动、停止
  • 🗑️ 批量清除应用数据
  • 📱 批量设备投屏 (scrcpy集成)
  • ⚙️ 灵活的配置管理
  • 📊 详细的设备信息显示
  • 🔧 命令行界面
  • 📝 完整的日志记录
  • 🔄 错误重试机制

安装

npm install

配置

配置文件管理

ADB Batch Manager 使用 强制配置 模式,必须创建配置文件才能使用。支持项目级和全局配置:

# 创建项目级配置文件(当前目录)
./bin/cli.js config --init

# 创建全局配置文件(用户家目录)
./bin/cli.js config --init --global

配置文件优先级

  1. ./adb-batch.config.json (项目级配置) - 优先级最高
  2. ~/adb-batch.config.json (全局配置) - 备选方案

配置文件结构

{
  "devices": [
    {
      "name": "Device 1",
      "ip": "192.168.1.152",
      "port": 5555,
      "enabled": true
    },
    {
      "name": "Device 2", 
      "ip": "192.168.1.104",
      "port": 5555,
      "enabled": true
    }
  ],
  "apps": {
    "courseassistant": {
      "packageName": "com.jckj.courseassistant1",
      "mainActivity": "com.jckj.courseassistant1.MainActivity",
      "apkPath": "./res/app-release.apk"
    }
  },
  "scrcpy": {
    "path": "scrcpy",
    "defaultOptions": [
      "--stay-awake",
      "--turn-screen-off"
    ],
    "windowOptions": {
      "width": 800,
      "maxFps": 30
    }
  },
  "settings": {
    "concurrent": 3,
    "timeout": 30000,
    "retries": 3,
    "logLevel": "info"
  }
}

配置说明

  • devices: 设备列表,包含设备名称、IP、端口和启用状态
  • apps: 应用配置,包含包名、主Activity和APK路径
  • scrcpy: 投屏配置,包含scrcpy路径、默认选项和窗口设置
  • settings: 全局设置,包含并发数、超时时间、重试次数和日志级别

配置管理命令

# 查看当前配置
./bin/cli.js config --show

# 查看配置帮助
./bin/cli.js config

使用方法

连接设备

./bin/cli.js connect

查看设备列表

# 简单列表
./bin/cli.js devices

# 详细信息
./bin/cli.js devices --info

应用管理

# 安装应用到所有设备
./bin/cli.js install myapp

# 安装到指定设备
./bin/cli.js install myapp -d "device1,device2"

# 启动应用
./bin/cli.js launch myapp

# 停止应用
./bin/cli.js stop myapp

# 卸载应用
./bin/cli.js uninstall myapp

# 清除应用数据
./bin/cli.js clear myapp

设备投屏

# 检查scrcpy安装
./bin/cli.js scrcpy --check

# 为所有设备启动投屏
./bin/cli.js scrcpy --start

# 为指定设备启动投屏
./bin/cli.js scrcpy --start -d "device1,device2"

# 自定义窗口标题
./bin/cli.js scrcpy --start --title "我的设备"

# 录屏到文件
./bin/cli.js scrcpy --start --record recording.mp4

# 无边框、置顶窗口
./bin/cli.js scrcpy --start --no-border --always-on-top

# 全屏模式
./bin/cli.js scrcpy --start --fullscreen

# 查看运行中的投屏进程
./bin/cli.js scrcpy --list

# 停止指定设备投屏
./bin/cli.js scrcpy --stop -d "device1"

# 停止所有投屏
./bin/cli.js scrcpy --stop

批量操作

# 传统的批量安装并启动
./bin/cli.js batch

# 指定应用的批量操作
./bin/cli.js batch -a myapp

查看配置

./bin/cli.js config --show

查看可用应用

./bin/cli.js apps

直接运行

如果你想使用传统方式(类似原始的install.js):

npm start

项目结构

src/
├── core/          # 核心功能模块
│   ├── adb.js     # ADB操作封装
│   ├── device.js  # 设备管理
│   └── app.js     # 应用管理
├── utils/         # 工具函数
│   ├── logger.js  # 日志系统
│   └── config.js  # 配置管理(单文件模式)
└── cli/           # 命令行接口
    └── commands/  # 各种命令处理器

配置文件:
├── ./adb-batch.config.json  # 项目级配置(优先)
└── ~/adb-batch.config.json  # 全局配置(备用)

设计特性

🎯 强制配置模式

  • 无默认配置: 避免意外使用错误的默认值
  • 明确配置: 用户必须明确定义设备和应用配置
  • 配置验证: 启动时验证配置文件的存在和有效性

📁 配置优先级

  • 项目级优先: ./adb-batch.config.json 优先级最高
  • 全局备用: ~/adb-batch.config.json 作为全局配置
  • npm兼容: 为 npm install -g 全局安装做准备

🔄 单文件配置

  • 简化管理: 只使用一个配置文件,不存在合并逻辑
  • 清晰明了: 配置内容完全可控,避免意外行为
  • 易于维护: 降低配置系统复杂度

日志

运行后会在 logs/ 目录下生成日志文件:

  • combined.log - 所有日志
  • error.log - 错误日志

scrcpy 投屏功能

🎯 关于 scrcpy

scrcpy 是最优秀的Android投屏解决方案:

  • 高性能:低延迟、高画质投屏
  • 功能丰富:支持录屏、文件传输、剪贴板同步
  • 跨平台:Windows、Linux、macOS全支持
  • 开源免费:GitHub 35k+ stars

📦 安装 scrcpy

# Windows
# 从 https://github.com/Genymobile/scrcpy/releases 下载

# Linux
sudo apt install scrcpy

# macOS
brew install scrcpy

⚙️ scrcpy配置选项

{
  "scrcpy": {
    "path": "scrcpy",                    // scrcpy命令路径
    "defaultOptions": [                  // 默认选项(已优化)
      "--stay-awake",                    // 保持设备常亮
      "--turn-screen-off",               // 关闭设备屏幕节省电量
      "--disable-screensaver",           // 禁用电脑屏保
      "--video-codec=h264",              // 使用H.264编码(兼容性好)
      "--video-bit-rate=6M",             // 视频码率6Mbps
      "--audio-bit-rate=128K"            // 音频码率128Kbps
    ],
    "windowOptions": {
      "width": 1024,                     // 窗口最大宽度
      "maxFps": 30                       // 最大帧率
    }
  }
}

注意事项

  1. 确保ADB已安装并在PATH中
  2. 确保Android设备已开启USB调试
  3. 网络连接设备需要先通过USB连接一次
  4. APK文件路径必须正确且文件存在
  5. 必须创建配置文件:工具采用强制配置模式,无配置文件将无法运行
  6. scrcpy可选:投屏功能需要单独安装scrcpy

npm 全局安装支持

未来发布到npm后,支持全局安装:

# 全局安装
npm install -g adb-batch-manager

# 创建全局配置
adb-batch config --init --global

# 在任意目录使用
adb-batch connect