XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEWorkflow

【WinUI】XFE基于windows的工作流

公开
关注 0 Fork 0 Star 0
UTF-8
param([Parameter(Mandatory)] [string]$Output, [Parameter(Mandatory)] [string]$Runner, [Parameter(Mandatory)] [string]$Standard, [Parameter(Mandatory)] [string]$Desktop, [Parameter(Mandatory)] [string]$Vision, [Parameter(Mandatory)] [string]$WeCom, [Parameter(Mandatory)] [string]$AgentBrowser)
$ErrorActionPreference = 'Stop'
$repoRoot = Split-Path $PSScriptRoot
function CopyTree([string]$source, [string]$destination) {
    New-Item -ItemType Directory -Force -Path $destination | Out-Null
    Get-ChildItem -LiteralPath $source -Force | ForEach-Object { Copy-Item -LiteralPath $_.FullName -Destination $destination -Recurse -Force }
}
CopyTree (Split-Path $Runner) (Join-Path $Output 'Runner')
$manifests = Join-Path $repoRoot 'XFEWorkflow\XFEWorkflow.Plugins.Standard\Manifests'
Get-ChildItem -LiteralPath $manifests -Filter '*.json' | Where-Object { $_.BaseName -ne 'xfe.wecom' } | ForEach-Object {
    $destination = Join-Path $Output ("BundledPlugins\" + $_.BaseName + '\1.0.0')
    CopyTree (Split-Path $Standard) $destination
    Copy-Item -LiteralPath $_.FullName -Destination (Join-Path $destination 'plugin.json') -Force
}
$desktopDestination = Join-Path $Output 'BundledPlugins\xfe.desktop\1.0.0'
CopyTree (Split-Path $Desktop) $desktopDestination
Copy-Item -LiteralPath (Join-Path $repoRoot 'XFEWorkflow\XFEWorkflow.Plugins.Desktop\plugin.json') -Destination (Join-Path $desktopDestination 'plugin.json') -Force
$visionManifestPath = Join-Path $repoRoot 'XFEWorkflow\XFEWorkflow.Plugins.Vision\plugin.json'
$visionManifest = Get-Content -LiteralPath $visionManifestPath -Raw -Encoding UTF8 | ConvertFrom-Json
$bundleRoot = [IO.Path]::GetFullPath((Join-Path $Output 'BundledPlugins')).TrimEnd('\','/') + [IO.Path]::DirectorySeparatorChar
$visionRoot = [IO.Path]::GetFullPath((Join-Path $bundleRoot 'xfe.vision'))
if (!$visionRoot.StartsWith($bundleRoot, [StringComparison]::OrdinalIgnoreCase)) { throw '插件输出路径越界' }
# Build output only. Installed/pinned plugin versions in the user workspace stay intact.
if (Test-Path -LiteralPath $visionRoot) { Remove-Item -LiteralPath $visionRoot -Recurse -Force }
$visionDestination = Join-Path $visionRoot $visionManifest.version
CopyTree (Split-Path $Vision) $visionDestination
Copy-Item -LiteralPath $visionManifestPath -Destination (Join-Path $visionDestination 'plugin.json') -Force
$wecomManifestPath = Join-Path $repoRoot 'XFEWorkflow\XFEWorkflow.Plugins.WeCom\plugin.json'
$wecomManifest = Get-Content -LiteralPath $wecomManifestPath -Raw -Encoding UTF8 | ConvertFrom-Json
$wecomRoot = [IO.Path]::GetFullPath((Join-Path $bundleRoot 'xfe.wecom'))
if (!$wecomRoot.StartsWith($bundleRoot, [StringComparison]::OrdinalIgnoreCase)) { throw '插件输出路径越界' }
if (Test-Path -LiteralPath $wecomRoot) { Remove-Item -LiteralPath $wecomRoot -Recurse -Force }
$wecomDestination = Join-Path $wecomRoot $wecomManifest.version
CopyTree (Split-Path $WeCom) $wecomDestination
Copy-Item -LiteralPath $wecomManifestPath -Destination (Join-Path $wecomDestination 'plugin.json') -Force
CopyTree (Join-Path (Split-Path $WeCom) 'NativeBridge') (Join-Path $Output 'NativeBridge\WeCom')
$agentManifestPath = Join-Path $repoRoot 'XFEWorkflow\XFEWorkflow.Plugins.AgentBrowser\plugin.json'
$agentManifest = Get-Content -LiteralPath $agentManifestPath -Raw -Encoding UTF8 | ConvertFrom-Json
$agentDestination = Join-Path $bundleRoot ("xfe.agent-browser\" + $agentManifest.version)
New-Item -ItemType Directory -Path $agentDestination -Force | Out-Null
Get-ChildItem -LiteralPath (Split-Path $AgentBrowser) -Filter 'XFEWorkflow.Plugins.AgentBrowser*.dll' | ForEach-Object { Copy-Item -LiteralPath $_.FullName -Destination $agentDestination -Force }
Get-ChildItem -LiteralPath (Split-Path $AgentBrowser) -Filter 'XFEWorkflow.Plugins.AgentBrowser*.deps.json' | ForEach-Object { Copy-Item -LiteralPath $_.FullName -Destination $agentDestination -Force }
CopyTree (Join-Path (Split-Path $AgentBrowser) 'Chat') (Join-Path $agentDestination 'Chat')
CopyTree (Join-Path (Split-Path $AgentBrowser) 'Scripts') (Join-Path $agentDestination 'Scripts')
Copy-Item -LiteralPath $agentManifestPath -Destination (Join-Path $agentDestination 'plugin.json') -Force