@roxybrowser/jumpserver-deploy
v1.0.1
Published
Deploy static assets to remote servers via JumpServer Connection Token (SSH/SFTP)
Readme
jumpserver-deploy
通过 JumpServer Connection Token 将静态资源部署到远程服务器(SSH/SFTP)。
适用于企业微信扫码登录等无法直接 SSH 密码认证的场景:使用 Access Key 创建 Connection Token,经 KoKo 网关上传并解压。
安装
npm install jumpserver-deploy
# 或
pnpm add jumpserver-deploy要求 Node.js >= 20.12(使用 process.loadEnvFile)。
环境变量
JMS_BASE_URL=https://jumpweb.example.com
JMS_HOST=jumpweb.example.com
JMS_PORT=2222
JMS_ACCESS_KEY_ID=your-access-key-id
JMS_ACCESS_KEY_SECRET=your-access-key-secret
JMS_ORG_ID=00000000-0000-0000-0000-000000000002
JMS_SYSTEM_USERNAME=root快速开始
import path from 'node:path'
import {
JumpServerClient,
JumpServerDeployer,
createSplitZipPackages,
loadDeployEnvFile,
loadJumpServerConfigFromEnv,
} from 'jumpserver-deploy'
loadDeployEnvFile(path.resolve('.env.deploy'))
const config = loadJumpServerConfigFromEnv()
const packages = createSplitZipPackages({
sourceDir: './dist',
// 静态站点:先更新 js/css,最后再更新 html
isDelayedFile: relativePath => relativePath.endsWith('.html'),
})
const deployer = new JumpServerDeployer({
client: JumpServerClient.fromConfig(config),
jumpServerHost: config.host,
jumpServerPort: config.port,
})
await deployer.deploy({
targets: [
{
label: 'web-server',
assetId: '84416d8e-xxxx-xxxx-xxxx-xxxxxxxxxxxx',
remoteBasePath: '/var/www/app/dist',
},
],
packages,
systemUsername: config.systemUsername,
})API
| 导出 | 说明 |
|------|------|
| JumpServerClient | JumpServer REST API,创建/销毁 Connection Token |
| JumpServerDeployer | SSH/SFTP 上传 + 远程解压 |
| createSplitZipPackages | 将目录拆为主资源包 + 延后部署包 |
| loadJumpServerConfigFromEnv | 从环境变量读取 JumpServer 配置 |
| loadDeployEnvFile | 加载 .env.deploy 文件 |
发布
pnpm install
pnpm build
npm publish --access publicLicense
MIT
