gongxiangp2/scripts/README.md

35 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 脚本说明
部署相关脚本以 `scripts/git-incremental-deploy.ps1` 为当前默认口径。详细说明见 `docs/部署规范.md`、`docs/Git增量部署方案.md`、`docs/部署脚本安全说明.md`。
## 1. 部署
`scripts/git-incremental-deploy.ps1`:以 Git 仓库为唯一源码入口,构建机增量拉取源码并构建镜像,生产服务器只拉取镜像并替换容器。需要 PuTTY(`plink.exe`、`pscp.exe`);构建机密码走 `BUILD_SERVER_PASSWORD`,Git 认证走 `GIT_DEPLOY_USERNAME`/`GIT_DEPLOY_PASSWORD` 或 `GIT_AUTH_HEADER`。由维护人员执行。
```powershell
.\scripts\git-incremental-deploy.ps1 -DryRun
.\scripts\git-incremental-deploy.ps1 -Commit <commit-sha>
.\scripts\git-incremental-deploy.ps1 -Target shadow
```
Mac 入口 `scripts/git-incremental-deploy-macos.sh` 只负责调度,不构建生产镜像。根目录 `deploy-*.ps1` 属于本地历史脚本名(受 `.gitignore` 保护),不是仓库交付入口。
## 2. 历史素材导入
- `scripts/scan_spu_ledger.py` → `scripts/export_spu_ledger.py`:按 SPU / 组合 SPU / 版本工作区扫描真实素材目录,生成 SQLite 台账并导出批次。店铺归属按当前业务口径(`金牌项目-1`、`GBJP-*` 归顾家);`正版`、`盗版` 可进候选,`错误勿用`、`废稿`、`勿用` 默认跳过;ready 要求主图、SKU 图、详情图同时存在。
- `scripts/import-history-materials.ts`、`scripts/run-history-import-queue.ts`:导入执行入口。Windows 上连生产库 `--apply` 时必须配置 `HISTORY_IMPORT_REMOTE_UPLOADS_HOST=prod` 与 `HISTORY_IMPORT_REMOTE_UPLOADS_DIR`,否则脚本阻止执行。
- `scripts/hard-delete-history-materials.ts`:只用于已确认的旧批次错误素材,需 `--apply --confirm=HARD_DELETE_HISTORY_MATERIALS`。
## 3. Node 24 测试与 PR 检查
```sh
npm ci --legacy-peer-deps --no-audit --no-fund
npm --prefix apps/detail-agent-pi ci --no-audit --no-fund
npm run prisma:generate
npm run test:all
```
`test:all` 依次运行 Web Jest、根仓 Node 脚本测试、小壹智能体完整单测(含白标检查)。[PR 工作流](../.github/workflows/ci.yml) 运行在标签 `xiaoyi-3090` 的自托管 Runner 上,并交叉 `cargo check` Windows 客户端。
## 4. 知识库契约漂移
```sh
node scripts/check-kb-contract-drift.mjs <通用源导出目录> <小壹版本目录或出库根目录>
```
按模板和组件列出绑定、原稿、字体等资产、映射字段、页面、图层及产品资料必填项差异。兼容 `ps_assets` 和 `source.assets`,忽略映射版本号。退出码 `0` 一致、`1` 有漂移、`2` 输入无法完整校验。CI 变量为 `XIAOYI_KB_CONTRACT_SOURCE` 与 `XIAOYI_KB_CONTRACT_RELEASE`。