@aplus-frontend/build-cli
TypeScript icon, indicating that this package has built-in type declarations

2.0.6 • Public • Published

Aplus Build Cli

NPM Version NPM Downloads NPM License

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>

方法

buildAllApp

类型: function buildAllApp(branchName?: string, afterBuild?: () => void): Promise<void>

描述: 该函数会遍历配置文件中的所有子应用名称和对应的远程仓库地址,依次拉取代码并复制到目标目录

参数

参数 类型 默认 描述
branchName string master 分支名字
afterBuild () => void - 远程拉取全部业务应用并拷贝之后的回调函数

buildOneApp

类型: function buildOneApp(subAppName: string, branchName: string, repoUrl: string, afterBuild?: () => void): Promise<void>;

描述: 该函数会拉取指定子应用的代码并复制到目标目录

参数

参数 类型 默认 描述
subAppName string - 业务应用名称
branchName string - 分支名字
repoUrl string - 远程仓库地址,推荐https格式
afterBuild () => void - 远程拉取业务应用并拷贝之后的回调函数

Readme

Keywords

Package Sidebar

Install

npm i @aplus-frontend/build-cli

Weekly Downloads

368

Version

2.0.6

License

MIT

Unpacked Size

64.1 kB

Total Files

12

Last publish

Collaborators

  • hemuxue
  • lonelyfkinging
  • huimin2000
  • rainiexxx
  • huaz
  • ollieliu
  • limoer
  • asd517665931
  • zxlin429
  • kuguago
  • chopinnn
  • wolfcq