aplus构建拉取应用脚本,三条线的业务应用会在构建阶段,合并拉取成一个发布应用。
提示: 仅
构建应用
需要使用该脚本,业务应用
不需要。
pnpm add @aplus-frontend/build-cli -D -w
// 构建应用中
// 根路径下的 scripts/build
import { buildAllApp } from "@aplus-frontend/build-cli";
import { execSync } from "child_process";
async function bootstrap() {
// 拉取远程业务应用代码并构建
await buildAllApp("master", () => {
execSync(`pnpm build`, {
stdio: "inherit",
encoding: "utf8",
});
});
}
bootstrap();
为了避免频繁的输入操作,可以在项目根目录下配置.aplus-build-rc
文件,接收一个json配置。
以下是一个例子:
{
"subAppRemoteAddress": {
"subapp-mos": "https://xxx/frontend/aplus-user-group/aplus-user-mos.git",
"subapp-wms": "https://xxx/frontend/aplus-user-group/aplus-user-wms.git",
"subapp-bms": "https://xxx/frontend/aplus-user-group/aplus-user-bms.git"
}
}
配置参数 | 配置值描述 | 类型 |
---|---|---|
subAppRemoteAddress | 业务应用对应的远程地址映射,key 作为在发布应用中生成的文件夹名字,value 是远程拉取业务应用的地址 |
Record<string, string> |
类型: function buildAllApp(branchName?: string, afterBuild?: () => void): Promise<void>
描述: 该函数会遍历配置文件中的所有子应用名称和对应的远程仓库地址,依次拉取代码并复制到目标目录
参数
参数 | 类型 | 默认 | 描述 |
---|---|---|---|
branchName | string |
master |
分支名字 |
afterBuild | () => void |
- | 远程拉取全部业务应用并拷贝之后的回调函数 |
类型: function buildOneApp(subAppName: string, branchName: string, repoUrl: string, afterBuild?: () => void): Promise<void>;
描述: 该函数会拉取指定子应用的代码并复制到目标目录
参数
参数 | 类型 | 默认 | 描述 |
---|---|---|---|
subAppName | string |
- | 业务应用名称 |
branchName | string |
- | 分支名字 |
repoUrl | string |
- | 远程仓库地址,推荐https 格式 |
afterBuild | () => void |
- | 远程拉取业务应用并拷贝之后的回调函数 |