# @cloudbase/framework-plugin-mp

> 云开发 Tencent CloudBase Framework MiniProgram Plugin 插件，可以一键部署项目下的微信小程序应用。

Latest version **1.9.7** (published 2024-02-03) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install @cloudbase/framework-plugin-mp
pnpm add @cloudbase/framework-plugin-mp
yarn add @cloudbase/framework-plugin-mp
bun add @cloudbase/framework-plugin-mp
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.9.7 |
| Published | 2024-02-03 |
| First published | 2020-09-17 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 39.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1996 |
| Author | Tencent CloudBase Team |
| Maintainers | yuzhen, woodenstone, justan, miusuncle, wangjiachen, wedabot, barretyi, daniel-dx, issacliu, liuyanjie, bobbyzhao, starkwang, yhyang, binggg, fengkx |

## Links

- npm: https://www.npmjs.com/package/@cloudbase/framework-plugin-mp
- Repository: https://github.com/Tencent/cloudbase-framework
- Homepage: https://github.com/Tencent/cloudbase-framework#readme
- Issues: https://github.com/Tencent/cloudbase-framework/issues
- npm.io page: https://npm.io/package/@cloudbase/framework-plugin-mp

## Dependencies (2)

- [miniprogram-ci](https://npm.io/package/miniprogram-ci.md) 1.0.76
- [@cloudbase/framework-core](https://npm.io/package/@cloudbase/framework-core.md) ^1.9.7

## Recent versions

- 1.9.7 (latest) — 2024-02-03
- 1.8.18-beta.1 (beta) — 2021-12-28
- 1.2.0-alpha.0 (bata) — 2020-09-17
- 1.9.6 — 2022-08-23
- 1.9.5 — 2022-08-22
- 1.9.5-beta.1 — 2022-07-24
- 1.9.5-beta.0 — 2022-07-22
- 1.3.6-beta.9 — 2022-07-21
- 1.9.4 — 2022-06-06
- 1.9.0 — 2021-12-28
- 1.8.16 — 2021-09-10
- 1.8.15 — 2021-09-08
- 1.8.13 — 2021-08-16
- 1.8.12 — 2021-08-16
- 1.8.11 — 2021-08-16
- … 83 more at https://npm.io/package/@cloudbase/framework-plugin-mp/versions

## README

<a href="https://github.com/Tencent/cloudbase-framework/tree/master/packages/framework-plugin-mp">![Tencent CloudBase Framework MP Plugin](https://main.qcloudimg.com/raw/3de9cef4b6ac7c72f9519f13d063fc13.jpg)</a>

# Tencent CloudBase Framework MiniProgram Plugin

[![Github License](https://img.shields.io/badge/license-Apache--2.0-blue)](LICENSE)
[![Npm version](https://img.shields.io/npm/v/@cloudbase/framework-plugin-container)](https://www.npmjs.com/package/@cloudbase/framework-plugin-container)
[![issue](https://img.shields.io/github/issues/Tencent/cloudbase-framework)](https://github.com/Tencent/cloudbase-framework/issues)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/Tencent/cloudbase-framework/pulls)
[![star](https://img.shields.io/github/stars/Tencent/cloudbase-framework?style=social)](https://github.com/Tencent/cloudbase-framework)

**云开发 CloudBase Framework 框架「小程序」插件**： 通过云开发 **[CloudBase Framework](https://github.com/Tencent/cloudbase-framework)** 框架一键部署微信小程序应用。

## 功能特性

## 使用方法

### 步骤一. 准备工作

具体步骤请参照 [准备云开发环境和 CloudBase CLI 命令工具](../../CLI_GUIDE.md)

### 步骤二. 进入项目目录进行初始化

如果是目前已有的小程序应用项目

```bash
cloudbase
```

### 步骤三. 一键部署

```bash
cloudbase framework deploy
```

## 配置

默认情况下仅需要配置 `appid`、`privateKeyPath` 即可使用，以下配置参数针对有特殊需求的场景

### 配置示例

`cloudbase init` 之后会创建云开发的配置文件 `cloudbaserc.json`，可在配置文件的 plugins 里修改和写入插件配置

```json
{
  "envId": "{{envId}}",
  "framework": {
    "plugins": {
      "client": {
        "use": "@cloudbase/framework-plugin-mp",
        "inputs": {
          "appid": "",
          "privateKeyPath": "",
          "localPath": "./",
          "ignores": ["node_modules/**/*"],
          "deployMode": "preview",
          "previewOptions": {
            "desc": "CloudBase Framework 一键预览",
            "setting": {
              "es6": true
            },
            "qrcodeOutputPath": "./qrcode.jpg",
            "pagePath": "pages/index/index"
          }
        }
      }
    }
  }
}
```

> 默认模板的 `appid` 和 `privateKeyPath` 为空，需要开发者填入

### 配置参数说明

### `appid`

必填，小程序应用的 appid

### `privateKey`

选填，小程序应用的部署私钥内容，需要经过 base64 编码

可以使用 [小程序部署密钥转换小工具](https://framework-1258016615.tcloudbaseapp.com/mp-key-tool/) 来转换为 Base64

### `privateKeyPath`

选填，小程序应用的部署私钥的本地相对路径，默认值 "./private.key"


### commands 

选填，对象格式

自定义命令，声明应用安装/构建的自定义命令，会在当前项目目录下进行执行


#### `commands.install`

安装命令，如`npm install`，没有可不传

默认会在小程序目录执行 `npm install --prefer-offline --no-audit --progress=false`

#### `commands.build`

构建命令，如`npm run build`，没有可不传

### `localPath`

选填，小程序项目 `project.config.json` 所在的本地路径，默认值 `./`

### `ignores`

选填，小程序应用部署时忽略的文件路径，支持通配符，默认值`["node_modules/**/*"]`

### `deployMode`

选填，小程序应用的部署模式，支持 `preview|upload` 2 种部署模式

### `previewOptions`

`deployMode` 填写为 `preview` 时需要填写`previewOptions`，类型是对象格式

| 属性名称         | 类型                          | 是否必填 | 描述                             |
| ---------------- | ----------------------------- | -------- | -------------------------------- |
| desc             | String                        | 否       | 小程序应用的版本描述             |
| setting          | IMiniProgramBuildSetting 对象 | 否       | 小程序应用的编译设置             |
| qrcodeOutputPath | String                        | 否       | 生成的预览二维码保存在本地的路径 |
| pagePath         | String                        | 否       | 小程序应用的预览页面地址         |
| searchQuery      | String                        | 否       | 小程序应用的预览页面参数         |
| scene            | Number                        | 否       | 小程序应用的预览页面场景值       |

例如

```json
{
  "envId": "{{envId}}",
  "framework": {
    "plugins": {
      "client": {
        "use": "@cloudbase/framework-plugin-mp",
        "inputs": {
          "appid": "",
          "privateKey": "",
          "localPath": "./",
          "ignores": ["node_modules/**/*"],
          "deployMode": "preview",
          "previewOptions": {
            "desc": "一键预览",
            "setting": {
              "es6": false
            },
            "qrcodeOutputPath": "./qrcode.jpg",
            "pagePath": "pages/index/index",
            "searchQuery": "",
            "scene": 1011
          }
        }
      }
    }
  }
}
```

### `uploadOptions`

`deployMode` 填写为 `upload` 时需要填写`uploadOptions`，类型是对象格式

| 属性名称 | 类型                          | 是否必填 | 描述                   |
| -------- | ----------------------------- | -------- | ---------------------- |
| version  | String 对象                   | 否       | 小程序应用上传的版本号 |
| desc     | String 对象                   | 否       | 小程序应用的版本描述   |
| setting  | IMiniProgramBuildSetting 对象 | 否       | 小程序应用的编译设置   |

例如

```json
{
  "envId": "{{envId}}",
  "framework": {
    "plugins": {
      "client": {
        "use": "@cloudbase/framework-plugin-mp",
        "inputs": {
          "appid": "",
          "privateKey": "",
          "localPath": "./",
          "ignores": ["node_modules/**/*"],
          "deployMode": "upload",
          "uploadOptions": {
            "version": "1.0.0",
            "desc": "CloudBase Framework 一键上传",
            "setting": {
              "es6": false
            }
          }
        }
      }
    }
  }
}
```

## 更多插件

请访问 [CloudBase Framework 插件列表](https://github.com/Tencent/cloudbase-framework#%E7%9B%AE%E5%89%8D%E6%94%AF%E6%8C%81%E7%9A%84%E6%8F%92%E4%BB%B6%E5%88%97%E8%A1%A8) 搭配使用其他插件

## 文档资料

- 云开发官网地址： [https://cloudbase.net/](https://cloudbase.net/)
- 云开发静态网站开通指南：[https://docs.cloudbase.net/hosting/](https://docs.cloudbase.net/hosting/)
- 云开发控制台地址： [https://console.cloud.tencent.com/tcb](https://console.cloud.tencent.com/tcb?tdl_anchor=github&tdl_site=0)

---
_Source: https://npm.io/package/@cloudbase/framework-plugin-mp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
