shipfe-node
v0.1.2
Published
Node.js version of shipfe deploy tool
Downloads
32
Readme
shipfe-node
基于 Node.js 的前端静态资源部署 CLI,行为与 shipfe-rust 中的 init / deploy / rollback 流程对齐,可在 Windows、macOS、Linux 上运行。
环境要求
- Node.js 18+(推荐 LTS)
安装
npm install -g shipfe-node
# 或项目内
npm install -D shipfe-node本地开发可直接:
node ./bin/shipfe.js --help快速开始
初始化配置(生成
.shipfe/管理目录):npx shipfe init按环境编辑
.shipfe/shipfe.config.json(主机、路径、子环境等)。部署:
npx shipfe deploy --profile prod
常用命令
| 命令 | 说明 |
|------|------|
| shipfe init | 生成默认 .shipfe/shipfe.config.json、.shipfe/scripts/zip-dist.mjs,并维护 .gitignore |
| shipfe deploy --profile <环境> | 按配置部署到指定环境 |
| shipfe deploy --profile <环境> --all-sub | 部署该环境下所有子环境(按配置顺序) |
| shipfe deploy --profile <环境> --config <路径> | 指定配置文件路径 |
| shipfe deploy --profile <环境>-<子环境> | 只部署某个子环境,例如 pre-admin |
| shipfe rollback --profile <环境> --to <版本号> | 回滚到指定 release 目录名(时间戳) |
配置文件
默认读取当前目录下的 .shipfe/shipfe.config.json;如果老项目只存在根目录 shipfe.config.json,仍会兼容读取。配置结构与 Rust 版一致,包含:
environments:各环境名称 →build_command、local_dist_path、servers、remote_tmp、sub_environments、hashed_asset_patterns、enable_shared、keep_releases等。
初始化产物
shipfe init 会在当前项目根目录生成 .shipfe/ 管理目录,把配置、日志、通用打包脚本和本地 zip 产物集中在一起:
.shipfe/shipfe.config.json:部署配置.shipfe/shipfe.log:部署日志.shipfe/scripts/zip-dist.mjs:通用dist打包脚本.shipfe/dist.zip:打包脚本生成的本地 zip 产物
如果业务项目已存在 .shipfe/scripts/zip-dist.mjs,会保留原文件。.shipfe/ 会自动加入 .gitignore;旧版根目录的 shipfe.config.json、shipfe.log、dist.zip 也会继续加入忽略,避免误提交。
如需本地生成 dist.zip,可在业务项目中执行:
node .shipfe/scripts/zip-dist.mjsSSH 认证
按以下优先级尝试(与 Rust 版思路一致):
servers[].password- 环境变量
SSH_PRIVATE_KEY(私钥内容) servers[].key_path(支持~展开为家目录)
日志
部署过程会写入当前目录 .shipfe/shipfe.log。
许可证
MIT
