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

@adtkcn/hb-cli

v2.0.3

Published

用于uniapp的打包工具,可切换环境变量、可多配置,切换证书,更改版本,wifi调试

Readme

功能

  • 简化打包:安卓、ios,本地打包App资源、wgt包
  • 切换打包配置:根据packConfig()返回的对象打包
  • 切换环境变量:根据appConfig.create()返回的对象生成js文件
  • 切换manifest参数:根据mergeManifestConfig()返回的对象合并manifest.json文件
  • 升级manifest版本号:可自动加一、当前日期、自定义版本号
  • wifi调试
  • 自动下载ios包到本地
  • 打包回调:打包完成后回调,可自定义回调函数用于上传等操作

运行

  • 本地安装 npm i -D @adtkcn/hb-cli
  • 在项目根目录下创建配置文件 hb-cli.config.js
  • 系统变量里加入HBuilder,指向 HBuilder 编辑器安装目录 环境变量
  • 在项目下直接运行命令
npx hb-cli --mode base

可以将命令定义在package.json中方便使用

{
  "scripts": {
    "build:dev": "hb-cli --mode dev",
    "build:prod": "hb-cli --mode prod"
  },
}

hb-cli.config.js,内容如下:

packConfig返回的对象都是官方配置,其中platform,iscustom字段无需填写

https://hx.dcloud.net.cn/cli/pack?id=config

/**
 * defineConfig:用于强化类型,可忽略
 * deepAssign:深度合并对象,可能需要用到,可忽略
 */
const { defineConfig, deepAssign } = require("@adtkcn/hb-cli");

/**
 *
 * @param {object} param0
 * @param {string} param0.mode 打包模式,通过命令行参数--mode传入
 * @returns
 */
module.exports = ({ mode }) => {
  console.log("当前mode环境:", mode);

  return defineConfig({
    // 打包配置项,全部为uniapp官方配置(必须)
    packConfig() {
      return {
        //项目名字或项目绝对路径
        project: "消息订阅1",

        //打包平台 默认值android  值有"android","ios" 如果要打多个逗号隔开打包平台
        platform: "android", // 无需填写
        //是否使用自定义基座 默认值false  true自定义基座 false自定义证书
        iscustom: false, // 无需填写
        //打包方式是否为安心打包默认值false,true安心打包,false传统打包
        safemode: true,
        //android打包参数
        android: {
          //安卓包名
          packagename: "cn.adtk.push",
          //安卓打包类型 默认值0: 0 使用自有证书 1 使用公共证书 2 使用老版证书 3云端证书
          androidpacktype: "3",

          //安卓打包证书别名,自有证书打包填写的参数
          certalias: "zdhlapp",
          //安卓打包证书文件路径,自有证书打包填写的参数
          certfile: "a",
          //安卓打包证书密码,自有证书打包填写的参数
          certpassword: "password",
          //安卓平台要打的渠道包 取值有"google","yyb","360","huawei","xiaomi","oppo","vivo",如果要打多个逗号隔开
          channels: "",
        },
        //ios打包参数
        ios: {
          //ios appid
          bundle: "cn.adtk.push",
          //ios打包支持的设备类型 默认值iPhone 值有"iPhone","iPad" 如果要打多个逗号隔开打包平台
          supporteddevice: "iPhone,iPad",
          //iOS打包是否打越狱包,只有值为true时打越狱包,false打正式包
          isprisonbreak: false,
          //iOS使用自定义证书打包的profile文件路径
          profile: "a",
          //iOS使用自定义证书打包的p12文件路径
          certfile: "a",
          //iOS使用自定义证书打包的证书密码
          certpassword: "",
        },
        //是否混淆 true混淆 false关闭
        isconfusion: false,
        //开屏广告 true打开 false关闭
        splashads: false,
        //悬浮红包广告true打开 false关闭
        rpads: false,
        //push广告 true打开 false关闭
        pushads: false,
        //加入换量联盟 true加入 false不加入
        exchange: false,
      };
    },
    // 自定义manifest.json配置项: 合并到manifest.json中(可选)
    mergeManifestConfig() {
      return {
        name: "消息订阅_11111",
      };
    },
    /**
     * 创建APP内环境变量,生成HBuilderEnv.js文件(可选)
     * @returns {any} 环境变量
     */
    appConfig:{
      output:"./HBuilderEnv.js", // 默认./HBuilderEnv.js
      create(){
        var info = {
          dev: {
            url: "https://base.adtk.cn",
          },
          prod: {
            url: "https://prod.adtk.cn",
          },
        };
        if (mode == "dev") {
          return info.dev;
        }
        return info.prod;
      },
    },
    /**
     * 定义manifest.versionName的生成规则(可选,默认:auto-increment)
     */
    version: {
      mode: "date", // 可选值:"custom"、"date"、"auto-increment",
      /**
       * 自定义版本号(可选)
       * @param {string[]} VersionNameArr 版本号数组,如:[1, 0, 0]
       * @returns {string} 版本号,如:1.0.0
       */
      customVersion: (VersionNameArr) => {
        console.log(VersionNameArr);
        var lastIndex = VersionNameArr.length - 1;
        VersionNameArr[lastIndex] = String(
          parseInt(VersionNameArr[lastIndex]) + 1
        );
        return VersionNameArr.join(".");
      },
    },

    /**
     * 打包回调:因为多种文件类型,appResource打包后是目录,所以需要自己处理
     * @param {string} filePath 文件路径
     * @param {"android"|"ios"| "appResource"| "wgt"} fileType 文件类型
     */
    async onPackEnd(filePath, fileType) {
      //上传回调
      console.log(filePath, fileType);
    },
  });
};

更新日志

change.md

旧版本说明

v1版本说明

Git需要忽略的文件

.hbuilderx/hb-cli.pack.json
.hbuilderx/hb-cli.ip.json

wifi调试用到的命令参考

D:\办公软件\HBuilderX\plugins\launcher\tools\adbs\adb.exe tcpip 5555
D:\办公软件\HBuilderX\plugins\launcher\tools\adbs\adb.exe connect 192.168.3.2

广告