zy-gbs-cmd/README.md

93 lines
1.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

# zy-gbs-cmd
`zy-gbs-cmd` 用于构建前端项目,并将构建产物提交到业务项目配置的 Java Git 仓库。
工具不调用授权接口也不保存账号密码。Git 克隆和推送使用当前电脑已有的 Git 凭据。
## 环境要求
- Node.js 18 或更高版本
- Git
- Yarn
`src/push.js` 使用的模块均为 Node.js 内置模块,无需安装运行时依赖。
业务项目的依赖安装和项目构建只使用 YarnWindows 下会自动调用 `yarn.cmd`
## 安装
安装已发布版本可以使用 npm 或 Yarn
```bash
npm install -g zy-gbs-cmd
```
```bash
yarn global add zy-gbs-cmd
```
本地安装当前目录:
```bash
npm install -g
```
## 业务项目配置
在业务项目根目录创建或修改 `jjb.config.js`
`javaGit` 必须是完整的 Git 克隆地址,不能只填写 Git 服务地址。
## 使用
在业务项目根目录执行:
```bash
zy-gbs-cmd push java
```
也可以直接指定环境:
```bash
zy-gbs-cmd push java production
```
指定环境后会自动执行同名构建脚本,例如 `production` 对应 `build:production`,不再询问构建命令和环境。
工具会把:
```text
dist/index.html
dist/<appIdentifier>/
```
复制到 Java 仓库:
```text
start/src/main/resources/templates/<appIdentifier>.html
start/src/main/resources/templates/<appIdentifier>/
```
工具只暂存和提交当前应用在 `templates` 下的目录及 HTML不会提交 Java 仓库其他路径的文件。
## 发布到 npm Registry
登录 Registry
```bash
yarn login
```
首次发布:
```bash
yarn publish
```
后续发布前需要先更新版本号,例如:
```bash
yarn version --patch
yarn publish
```