fix: emit file:// plugin URLs for dsh ESM loader on Windows

This commit is contained in:
2026-09-04 12:08:37 +08:00
parent 01218b2907
commit a14a8d9233
3 changed files with 9 additions and 7 deletions
+4 -3
View File
@@ -19,14 +19,15 @@ param(
$ErrorActionPreference = 'Stop' $ErrorActionPreference = 'Stop'
$RepoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path $RepoRoot = (Resolve-Path (Join-Path $PSScriptRoot '..\..')).Path
$WorkbenchDir = Join-Path $RepoRoot 'workbench' $WorkbenchDir = Join-Path $RepoRoot 'workbench'
$PluginDir = Join-Path $WorkbenchDir 'plugin'
$LocalYml = Join-Path $WorkbenchDir 'cordis.local.yml' $LocalYml = Join-Path $WorkbenchDir 'cordis.local.yml'
# 1) 渲染 cordis.local.yml # 1) 渲染 cordis.local.yml
$template = Get-Content (Join-Path $WorkbenchDir 'cordis.template.yml') -Raw -Encoding UTF8 $template = Get-Content (Join-Path $WorkbenchDir 'cordis.template.yml') -Raw -Encoding UTF8
$pluginDirPosix = ($PluginDir -replace '\\', '/') $workbenchDirPosix = ($WorkbenchDir -replace '\\', '/')
$projectRootPosix = ($RepoRoot -replace '\\', '/') $projectRootPosix = ($RepoRoot -replace '\\', '/')
$rendered = $template.Replace('__PLUGIN_DIR__', $pluginDirPosix).Replace('__PROJECT_ROOT__', $projectRootPosix) # Windows 上 dsh 的 ESM 加载器要求 file:// URL
$workbenchModuleUrl = 'file:///' + $workbenchDirPosix
$rendered = $template.Replace('__WORKBENCH_DIR__', $workbenchModuleUrl).Replace('__PROJECT_ROOT__', $projectRootPosix)
$rendered = $rendered -replace 'bridgePort: 8790', "bridgePort: $BridgePort" $rendered = $rendered -replace 'bridgePort: 8790', "bridgePort: $BridgePort"
$rendered = $rendered -replace "consoleBaseUrl: 'http://127.0.0.1:8765'", "consoleBaseUrl: 'http://127.0.0.1:$ConsolePort'" $rendered = $rendered -replace "consoleBaseUrl: 'http://127.0.0.1:8765'", "consoleBaseUrl: 'http://127.0.0.1:$ConsolePort'"
[System.IO.File]::WriteAllText($LocalYml, $rendered, (New-Object System.Text.UTF8Encoding($false))) [System.IO.File]::WriteAllText($LocalYml, $rendered, (New-Object System.Text.UTF8Encoding($false)))
+2 -1
View File
@@ -11,8 +11,9 @@ CONSOLE_PORT="${GYXX_CONSOLE_PORT:-8765}"
BRIDGE_PORT="${GYXX_WB_BRIDGE_PORT:-8790}" BRIDGE_PORT="${GYXX_WB_BRIDGE_PORT:-8790}"
# 1) 渲染 cordis.local.yml(插件路径必须为绝对路径) # 1) 渲染 cordis.local.yml(插件路径必须为绝对路径)
# dsh 的 ESM 加载器要求 file:// URLWindows 上必须,POSIX 上同样可用)
sed \ sed \
-e "s|__PLUGIN_DIR__|$WORKBENCH_DIR/plugin|g" \ -e "s|__WORKBENCH_DIR__|file://$WORKBENCH_DIR|g" \
-e "s|__PROJECT_ROOT__|$REPO_ROOT|g" \ -e "s|__PROJECT_ROOT__|$REPO_ROOT|g" \
-e "s|bridgePort: 8790|bridgePort: $BRIDGE_PORT|g" \ -e "s|bridgePort: 8790|bridgePort: $BRIDGE_PORT|g" \
-e "s|http://127.0.0.1:8765|http://127.0.0.1:$CONSOLE_PORT|g" \ -e "s|http://127.0.0.1:8765|http://127.0.0.1:$CONSOLE_PORT|g" \
+3 -3
View File
@@ -1,11 +1,11 @@
# GYXX 智能工作台 —— dsh Web 组合补丁(模板)。 # GYXX 智能工作台 —— dsh Web 组合补丁(模板)。
# 启动脚本会把 __PLUGIN_DIR__ / __PROJECT_ROOT__ 渲染为绝对路径后生成 # 启动脚本会把 __WORKBENCH_DIR__ / __PROJECT_ROOT__ 渲染为绝对路径后生成
# cordis.local.yml,再通过 `dsh web --patch workbench/cordis.local.yml` 加载。 # cordis.local.yml,再通过 `dsh web --patch workbench/cordis.local.yml` 加载。
# 不要直接手工使用本文件:dsh 要求插件路径为绝对路径。 # 不要直接手工使用本文件:dsh 要求插件路径为绝对路径Windows 上必须是 file:// URL
- insert: - insert:
- id: gyxx-workbench - id: gyxx-workbench
name: '__PLUGIN_DIR__/plugin/gyxx-workbench.mjs' name: '__WORKBENCH_DIR__/plugin/gyxx-workbench.mjs'
config: config:
# gyxx 控制台 HTTP APIgyxx console,默认 8765 端口) # gyxx 控制台 HTTP APIgyxx console,默认 8765 端口)
consoleBaseUrl: 'http://127.0.0.1:8765' consoleBaseUrl: 'http://127.0.0.1:8765'