| | |
| | | |
| | | const testWebDir = 'E:/Wi/web/test'; |
| | | // 忽略同步的目录 |
| | | const ignoreProj = ['prod']; |
| | | // 同步时需要保留的文件路径(相对路径) |
| | | const ignoreSyncPath = ['static/config/globalConfig.js']; |
| | | // 部署后同步文件到同层其他项目目录,且忽略项目配置文件 |
| | | const remoteRunAfter = `cd /d ${testWebDir} && powershell -Command "$currentDir = Split-Path -Leaf (Get-Location); $ignoreDirs = @('${ignoreProj.join( |
| | | "','" |
| | | )}', $currentDir); $ignoreSyncPaths = @('${ignoreSyncPath.join( |
| | | "','" |
| | | )}'); $parentDir = Split-Path (Get-Location) -Parent; Get-ChildItem $parentDir -Directory | Where-Object { -not $ignoreDirs.Contains($_.Name) } | ForEach-Object { $targetDir = $_.FullName; $backupFiles = @{}; foreach ($ignorePath in $ignoreSyncPaths) { $fullIgnorePath = Join-Path $targetDir $ignorePath; if (Test-Path $fullIgnorePath) { $tempPath = Join-Path $env:TEMP ('backup_' + [guid]::NewGuid().ToString()); Copy-Item -Path $fullIgnorePath -Destination $tempPath -Force; $backupFiles[$ignorePath] = $tempPath; } }; Get-ChildItem $targetDir -Recurse | Where-Object { $_.FullName -ne $targetDir } | Remove-Item -Force -Recurse; Get-ChildItem -Path '.' -Recurse -File | Where-Object { $relativePath = $_.FullName.Substring((Get-Location).Path.Length + 1); $shouldCopy = $true; foreach ($ignorePath in $ignoreSyncPaths) { if ($relativePath -like $ignorePath) { $shouldCopy = $false; break; } }; $shouldCopy } | ForEach-Object { $relativePath = $_.FullName.Substring((Get-Location).Path.Length + 1); $targetPath = Join-Path $targetDir $relativePath; $targetParent = Split-Path $targetPath -Parent; if (-not (Test-Path $targetParent)) { New-Item -Path $targetParent -ItemType Directory -Force | Out-Null }; Copy-Item -Path $_.FullName -Destination $targetPath -Force }; foreach ($ignorePath in $ignoreSyncPaths) { if ($backupFiles.ContainsKey($ignorePath)) { $fullIgnorePath = Join-Path $targetDir $ignorePath; $parentFolder = Split-Path $fullIgnorePath -Parent; if (-not (Test-Path $parentFolder)) { New-Item -Path $parentFolder -ItemType Directory -Force | Out-Null }; Move-Item -Path $backupFiles[$ignorePath] -Destination $fullIgnorePath -Force } } }"`; |
| | | module.exports = { |
| | | privateKeyPath: 'C:/ssh/id_rsa', // 本地私钥地址,位置一般在C:/Users/xxx/.ssh/id_rsa,非必填,有私钥则配置 |
| | | passphrase: '', // 本地私钥密码,非必填,有私钥则配置 |
| | |
| | | // 测试环境 |
| | | name: '测试环境', |
| | | preRun: '', // 测试环境打包脚本 |
| | | host: '101.133.133.173', // 测试服务器地址 |
| | | host: '47.100.245.85', // 测试服务器地址 |
| | | port: 22, // ssh port,一般默认22 |
| | | username: 'Administrator', // 登录服务器用户名 |
| | | password: '', // 登录服务器密码 |
| | | distPath: 'dist', // 本地打包dist目录 |
| | | webDir: 'E:/wi/web', // // 测试环境服务器地址 |
| | | webDir: testWebDir, // // 测试环境服务器地址 |
| | | |
| | | remoteIgnorePath: 'WI水务智能助手.apk', // 远程服务器忽略删除文件或文件夹,可填数组或字符串 |
| | | // 备份 |
| | | bakOld: { |
| | | // 备份个数,不填默认 3 个 |
| | |
| | | // 是否备份,默认启用备份 |
| | | enable: true, |
| | | }, |
| | | // 远程执行命令 |
| | | remoteRun: { |
| | | // 部署前执行命令 |
| | | before: '', |
| | | // 部署后执行命令 |
| | | after: remoteRunAfter, |
| | | }, |
| | | // 部署预览 |
| | | preview: { |
| | | url: 'http://101.133.133.173:8084/', // 部署后检查部署效果,查看的网页地址 |
| | | url: 'https://wi.beng35.com/web/test', // 部署后检查部署效果,查看的网页地址 |
| | | openInBrowser: false, // 部署完成后是否自动打开部署的网页地址 |
| | | }, |
| | | }, |
| | |
| | | // 线上环境 |
| | | name: '线上环境', |
| | | preRun: '', // 线上环境打包脚本 |
| | | host: '47.102.134.202', // 测试服务器地址 |
| | | host: '47.100.245.85', // 线上服务器地址 |
| | | port: 22, // ssh port,一般默认22 |
| | | username: 'administrator', // 登录服务器用户名 |
| | | password: '', // 登录服务器密码 |
| | | distPath: 'dist', // 本地打包dist目录 |
| | | webDir: 'D:/YW/wi', // 测试环境服务器地址 |
| | | webDir: 'E:/Wi/web/prod', // 线上环境服务器地址 |
| | | remoteIgnorePath: 'WI水务智能助手.apk', // 远程服务器忽略删除文件或文件夹,可填数组或字符串 |
| | | // 备份 |
| | | bakOld: { |
| | | // 备份个数,不填默认 3 个 |