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

@tqtjs/taro-plugin-mini-ci

v0.0.3

Published

Taro 小程序端构建后支持CI(持续集成)的插件

Downloads

4

Readme

@tqtjs/taro-plugin-mini-ci

Taro 小程序端构建后支持 CI(持续集成)的插件, 支持构建完毕后自动打开小程序开发这个工具、上传作为体验版、生成预览二维码. 目前支持 淘宝移动端 和 千牛PC

基于taobaodev实现

使用

安装

npm i taobaodev -g
npm i @tqtjs/taro-plugin-mini-ci -D

使用插件

/config/index.js

// 示例, 如果你使用 `vs code` 作为开发工具, 你还可以使用注释的语法引入插件包含的声明文件,可获得类似于typescript的友好提示
/**
 * @typedef { import("@tqtjs/taro-plugin-mini-ci").PluginOptions } PluginOptions
 * @type {PluginOptions}
 */
const PluginOptions = {
  projectPath: './dist',
  appId: 'xxxxx',
};
const config = {
  plugins: [['@tqtjs/taro-plugin-mini-ci', PluginOptions]],
};

除了给插件传入对象, 你也可以传入一个异步函数,在编译时动态返回相关配置。

const CIPluginFn = async () => {
  // 可以在这里做一些异步事情, 比如请求接口获取配置
  /**
   * @typedef { import("@tqtjs/taro-plugin-mini-ci").PluginOptions } PluginOptions
   * @type {PluginOptions}
   */
  return {
    projectPath: './dist',
    appId: 'xxxxx',
  };
};

const config = {
  plugins: [['@tqtjs/taro-plugin-mini-ci', CIPluginFn]],
};

作为选项配合 build 命令使用

package.jsonscripts 字段使用命令参数

{
  "scripts": {
    //  构建完后自动 “打开开发者工具”
    "build:tb": "taro build --type tb --open",
    //  构建完后自动 “上传代码作为开发版并生成预览二维码”
    "build:tb:preview": "taro build --type tb --preview",
    //  构建完后自动“上传代码作为体验版”
    "build:tb:upload": "taro build --type tb --upload",
    //  构建完后自动“上传 dist/xxx 目录的代码作为体验版”, `--projectPath` 参数 适用于 taro 和 原生混合的场景
    "build:tb:upload": "taro build --type tb --upload --projectPath dist/xxx"
  }
}

由上面的示例可知,插件为 taro cli 命令扩展了 4 个选项:

  • --open 类似于网页开发中自动打开谷歌浏览器
  • --preview 上传代码作为开发版并生成预览二维码
  • --upload 上传代码作为体验版

此 3 个选项在一条命令里不能同时使用(互斥)

  • --projectPath 指定要操作(打开、预览、上传)的目录路径, 默认情况下是操作构建后目录路径,即 outputRoot 选项

此选项必须搭配上述三个选项之一一起使用;

此选项优先级为: 终端传入的--projectPath > CI 配置的projectPath 选项 > outputRoot 选项

作为命令单独使用

{
  "scripts": {
    //  直接 “打开开发者工具并载入项目”
    "build:tb": "taro open --type tb  --projectPath dist/xxx",
    //  直接 “上传代码作为开发版并生成预览二维码”
    "build:tb:preview": "taro preview --type tb",
    //  直接“上传代码作为体验版”
    "build:tb:upload": "taro upload --type tb",
    //  上传指定目录代码作为体验版
    "build:tb:upload2": "taro upload --type tb --projectPath dist/xxx"
  }
}

由上面的示例可知,插件额外新增了 3 个独立命令,让你可以直接操作指定目录。适用于把 taro 作为项目一部分的使用场景。

当直接作为命令使用时,有两个选项:

  • --type 传入平台名称
  • --projectPath 传入路径。 此选项优先级为: 终端传入的--projectPath > CI 配置的projectPath 选项 > outputRoot 选项

API

插件配置

| 参数 | 类型 | 是否必填 | 说明 | | :---------- | :----- | :------- | :------------------------------------------------------------- | | appId | string | 是 | 项目的 appId | | projectPath | string | 否 | 上传的小程序的路径(默认取的 outputRoot )(3.6.0 版本已废弃) |

Q&A

  1. 如果提示用户未登录?

请先扫码登陆

taobaodev login