Socket
Book a DemoInstallSign in
Socket

@mario34/mp-ci

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@mario34/mp-ci

微信小程序ci

latest
Source
npmnpm
Version
1.2.2
Version published
Maintainers
1
Created
Source

小程序代码上传 ci

⏱ 小程序持续集成 ci,基于miniprogram-ci实现

快速配置

  • 安装开发依赖
yarn add @mario34/mp-ci -D
  • 添加发布脚本 mp-ci.mjs
import path from "path";
import run from "@mario34/mp-ci";
import packageJson from "./package.json";

run({
  config() {
    return {
      appid: "wxsomeappid",
      type: "miniProgram",
      projectPath: path.resolve(process.cwd(), "./dist/"),
      privateKeyPath: path.resolve(process.cwd(), "./dist/"),
      ignores: ["node_modules/**/*"],
    };
  },
  formatVersion() {
    return packageJson.version;
  },
  formatDesc(info) {
    // info包含了项目的部分信息,可以用来定制描述
    return packageJson.version;
  },
  setting() {
    return {
      es6: true,
      es7: true,
    };
  },
});
  • 添加脚本
{
  "scripts": {
    "ci": "node --experimental-modules --es-module-specifier-resolution=node ./mp-ci.mjs --log"
  }
}
  • 在微信公众平台添加相关配置

登录微信公众平台,前往 开发=>开发管理=>开发设置=>小程序代码上传,生成上传密钥,开启了上传白名单的话需要把 CI 物理机的 ip 加入到 ip 白名单

配置

项目信息

项目信息在配置为函数类型中作为参数暴露,类型如下

interface Info {
  git: {
    branch: string;
  };
}

config

返回项目配置对象的函数或配置对象

参数描述类型默认值必填
appid小程序 appidstring/
projectPath上传代码路径string/
type显示指明当前的项目类型 miniProgram、miniProgramPlugin、miniGame、miniGamePluginstringminiProgram
ignores排除的规则string[]['node_modules/**/*']
keyType密钥类型 file/rawstringfile

formatVersion

格式化版本号函数,返回版本号字符串,参数为暴露的项目信息

formatDesc

格式化描述信息函数,返回描述字符串,参数为暴露的项目信息

setting

上传设置

interface ICompileSettings {
  es6?: boolean;
  es7?: boolean;
  minify?: boolean;
  codeProtect?: boolean;
  minifyJS?: boolean;
  minifyWXML?: boolean;
  minifyWXSS?: boolean;
  autoPrefixWXSS?: boolean;
  disableUseStrict?: boolean;
}

Keywords

mini-program

FAQs

Package last updated on 15 Mar 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts