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 🙏

© 2024 – Pkg Stats / Ryan Hefner

imweapp

v1.0.5

Published

小程序构建npm,上传、生成预览二维码

Downloads

32

Readme

imweapp

imweapp 是基于miniprogram-ci进行的封装,提供了更方便的调用接口。

有以下基本功能:

  1. 构建 npm 前,会自动检测当前小程序项目以来的 npm 包是否需要更新,如果需要则执行更新并构建;
  2. 构建、预览、上传前,imweapp 会从当前项目遍历所有路径查找 private.[appid].key 作为默认私钥;
  3. 预览、上传前,会根据小程序设置判断是否需要构建 npm;
  4. 可自动获取 git 记录和项目 package.json 的版本号作为上传信息;

⚠️ 由于 imweapp 不依赖小程序开发者工具,所以执行构建上传及预览所需要进行的身份鉴权需要通过 privateKey 来校验,此密钥需要在 “微信公众平台 - 开发 - 开发设置” 下载。为了避免密钥被泄漏的风险,小程序官方开设置了 IP 白名单的限制,打开时只有在白名单内的服务 ip 才能通过 imweapp 进行代码操作。

安装下载

  1. 全局安装
$ npm install imweapp -g
  1. 项目安装
$ npm install imweapp --save-dev

快速上手

1. 构建 npm
$ imweapp build [projectPath] [--key privateKey]

build 命令会根据 app.json 下的配置信息,对分包和主包进行 npm 检查并执行构建,而没有进行分包配置的目录,即使安装了依赖也不会收到影响。

输入 projectPath 可以指定项目的根目录,默认当前执行路径位根目录,下同。

输入 privateKey 可以指定需要用到的私钥路径,默认从当前目录开始遍历所有路径查找 private.[appid].key 作为默认私钥,下同。

  • 如果你的 npm 模块需要更新会调用 npm install 进行更新;
  • 如果你使用的 cnpm 或者别的版本,可以通过 --npm cnpm 进行修改;
  • 如果你的小程序没有使用 npm 模块,将会给出提示。
  • 如果你希望未配置分包的目录也就行 npm 构建,可以通过 --all 指定
2. 小程序预览
$ imweapp preview [projectPath] [--key [privateKey]]

preview 命令下,如果小程序使用了 npm 依赖,会先对小程序执行 build 命令,然后进行编译并生成二维码。

  • 如果你的 npm 模块需要更新会调用 npm install 进行更新,如需修改 npm 工具,通过 --npm cnpm 进行修改;
  • 通过 -p --path <path>-q --query <query> 为预览指定页面路径和参数,如果有多个参数通过\&划分;
  • 通过 --type <type> 设置二维码版本,可选项:dev(default)-开发版, exp-体验版,体验版是小程序管理后台设置的体验版版本,跟本次构建没有强关联;
  • 通过 --qr-type <qrType> 二维码输出类型,可选项:image(default), base64, terminal;
  • 通过 --qr-dest <qrDest> 二维码输出路径;
  • 通过 -r --robot <robot> 指定执行上传的机器人,可选值:1-30;
3. 小程序上传
$ imweapp upload [projectPath] [--key [privateKey]]

upload 命令下,如果小程序使用了 npm 依赖,会先对小程序执行 build 命令,然后进行编译并上传至小程序管理后台。

  • 如果你的 npm 模块需要更新会调用 npm install 进行更新,如需修改 npm 工具,通过 --npm cnpm 进行修改;
  • 通过-v --ver <ver>指定上传的版本号,默认读取跟目录的 package.json 的 version 字段作为默认的版本号;
  • 通过-d --desc <desc>指定版本描述,默认读取本地的 git 提交记录最近 5 条以作为选择,否则自定义输入,目前只支持 git;
  • 通过 --auto 自动执行默认操作,一般接入 CI 流程开启;
  • 通过 -r --robot <robot> 指定执行上传的机器人,可选值:1-30;
4. 获取上传版本的 source map(zip)
$ imweapp sourcemap [projectPath] [--key [privateKey]]

获取当前机器人(default: 1)最近一次上传版本的 source map

  • 通过 -r --robot <robot> 指定执行上传的机器人,可选值:1-30;
  • 通过 -d --dest <dest> 指定 source map 的保存地址;
5. 打开开发者工具(暂时只支持 mac 端调用)
imweapp open [projectPath] [--tool-path]

打开小程序开发者工具

传入 projectPath 可以打开指定项目

  • 首次使用 cli 命令,需要先搜索并确认本地是否安装了开发者工具,会消耗一些时间(windows 平台首次使用 cli 命令需要确保安装开发者工具并运行);
  • 如果你通过--tool-path 提供正确的开发者工具命令行工具路径,就可以跳过搜索的过程。
6. 关闭开发者工具(暂时只支持 mac 端调用)
imweapp close [--tool-path]
  • 首次使用 cli 命令,需要先搜索并确认本地是否安装了开发者工具,会消耗一些时间(windows 平台首次使用 cli 命令需要确保安装开发者工具并运行);
  • 如果你通过--tool-path 提供正确的开发者工具命令行工具路径,就可以跳过搜索的过程。

问题

  1. Q: get new ticket fail innerCode: -80011;

    A: 这个错误表示所使用的密钥不对,或者被别人重置了,需要使用最新的密钥,或者到 “微信公众平台 - 开发 - 开发设置” 重新获取。

  2. Q: invalid ip: xx.xx.xx.xx, referce: https://developers.weixin.qq.com/miniprogram/dev/devtools/ci.html;

    A: 这个错误表示当前上传 ip 不在 IP 白名单内,需要到 “微信公众平台 - 开发 - 开发设置” 添加此 ip 到白名单。

如有更多问题请联系 [email protected]