Skip to content

Commit 869c681

Browse files
committed
feat: support merge mp
1 parent 8e1fe6c commit 869c681

6 files changed

Lines changed: 1634 additions & 261 deletions

File tree

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: MP_COMPOSE_PREVIEW
2+
3+
on:
4+
pull_request:
5+
types: [opened, synchronize, reopened]
6+
push:
7+
branches: [develop]
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: mp-compose-preview-${{ github.event.pull_request.number || github.sha }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
compose-preview:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v6
19+
with:
20+
ref: ${{ github.event.pull_request.head.sha || github.sha }}
21+
22+
- name: 安装 pnpm
23+
uses: pnpm/action-setup@v4
24+
25+
- name: 安装 Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: 20
29+
cache: pnpm
30+
31+
- name: 缓存外部仓库(复用 clone 和 node_modules)
32+
uses: actions/cache@v4
33+
with:
34+
path: .tmp-compose
35+
key: compose-repos-${{ runner.os }}
36+
37+
- name: 安装当前项目依赖
38+
run: pnpm install
39+
40+
- name: 融合构建
41+
run: node script/mp-compose-build.mjs
42+
43+
- name: 小程序预览/上传
44+
env:
45+
MINI_APP_ID: ${{ secrets.TDESIGN_UNI_APP_ID }}
46+
MINI_APP_PRIVATE_KEY: ${{ secrets.TDESIGN_UNI_MINI_KEY }}
47+
PR_AUTHOR: ${{ github.event.pull_request.user.login || github.actor }}
48+
PR_NUMBER: ${{ github.event.pull_request.number || '' }}
49+
PR_TITLE: ${{ github.event.pull_request.title || github.event.head_commit.message || 'compose preview' }}
50+
COMMIT_SHA: ${{ github.event.pull_request.head.sha || github.sha }}
51+
IS_PR: ${{ github.event_name == 'pull_request' && 'true' || 'false' }}
52+
run: node script/mp-preview.mjs --project-path=dist/mini-merge

guru.config.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const path = require('path');
2+
const apps = [
3+
{
4+
// project.config.json所在目录,其中 miniprogramRoot 指定小程序代码目录
5+
projectDir: path.resolve(__dirname, 'dist/build/mp-weixin-component'),
6+
type: 'main',
7+
},
8+
{
9+
projectDir: path.resolve(__dirname, 'dist/build/mp-weixin'),
10+
namespace: 'starter',
11+
type: 'single-independent', // 主应用-main 独立分包-single-independent 普通分包-single-normal 多分包-multi-origin
12+
},
13+
{
14+
projectDir: path.resolve(__dirname, 'dist/build/mp-weixin-starter-apply'),
15+
namespace: 'starter-apply',
16+
type: 'single-independent',
17+
},
18+
];
19+
module.exports = {
20+
compose: {
21+
apps,
22+
distDir: path.resolve(__dirname, 'dist/mini-merge'),
23+
},
24+
};

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,9 @@
5454
"lint:fix": "eslint --fix --ext .js,.ts,.vue .",
5555
"mp:ci": "node script/mp-preview.mjs",
5656
"mp:preview": "node script/mp-preview.mjs --mode=preview",
57-
"mp:upload": "node script/mp-preview.mjs --mode=upload"
57+
"mp:upload": "node script/mp-preview.mjs --mode=upload",
58+
"mp:compose": "node script/mp-compose-build.mjs",
59+
"mp:compose:preview": "npm run mp:compose && node script/mp-preview.mjs --project-path=dist/mini-merge"
5860
},
5961
"dependencies": {
6062
"@dcloudio/uni-app": "3.0.0-4080420251103001",
@@ -117,12 +119,16 @@
117119
"husky": "^9.1.7",
118120
"less": "^4.4.2",
119121
"lint-staged": "^16.2.7",
120-
"miniprogram-ci": "^2.1.26",
122+
"miniprogram-ci": "^2.1.31",
123+
"mp-guru-cli": "^1.0.14",
124+
"nanoid": "^5.1.7",
125+
"picocolors": "^1.1.1",
121126
"postcss": "8.4.49",
122127
"postcss-comment": "^2.0.0",
123128
"postcss-html": "1.6.0",
124129
"postcss-loader": "~3.0.0",
125130
"postcss-scss": "4.0.9",
131+
"source-map-js": "^1.2.1",
126132
"stylelint": "14.16.1",
127133
"stylelint-config-common": "1.0.10",
128134
"stylelint-plugin-light": "^1.0.17",

0 commit comments

Comments
 (0)