diff --git a/.gitea/workflows/devstar-vscode-release.yaml b/.gitea/workflows/devstar-vscode-release.yaml index ce4f729..a992f38 100644 --- a/.gitea/workflows/devstar-vscode-release.yaml +++ b/.gitea/workflows/devstar-vscode-release.yaml @@ -23,7 +23,7 @@ jobs: - name: 拉取代码 uses: actions/checkout@v4 with: - token: ${{ secrets.GITHUB_TOKEN }} + token: ${{ secrets.PAT_WITH_BYPASS }} # 使用具有绕过保护权限的 PAT fetch-depth: 0 - name: 配置 Git @@ -55,9 +55,11 @@ jobs: jq --arg version "$NEW_VERSION" '.version = $version' package.json > package.json.tmp mv package.json.tmp package.json - # 提交版本变更 + # 提交版本变更(包含 [skip ci] 避免触发循环构建) git add package.json git commit -m "chore: bump version to $NEW_VERSION [skip ci]" + + # 推送到保护分支(需要 PAT_WITH_BYPASS 有绕过保护的权限) git push - name: 安装依赖 diff --git a/package.json b/package.json index 1b52c91..ffcb232 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "devstar", "displayName": "%displayName%", "description": "%description%", - "version": "0.4.3", + "version": "0.4.4", "keywords": [], "publisher": "mengning", "engines": { diff --git a/src/remote-container.ts b/src/remote-container.ts index 9aa8e23..8c22f8b 100644 --- a/src/remote-container.ts +++ b/src/remote-container.ts @@ -27,39 +27,36 @@ export default class RemoteContainer { /** * 构建打开项目的命令 - * 在远程环境下,通过本地终端实时检测本地系统类型和 PowerShell 版本 - * 支持 Windows/Linux/Mac 作为本地系统的所有场景 + * 根据终端类型生成对应的命令 + * 支持 Windows PowerShell/CMD 和 Linux/macOS Bash/Zsh */ - private async buildOpenProjectCommand( + private buildOpenProjectCommand( host: string, hostname: string, port: number, username: string, path: string, - devstarDomain?: string - ): Promise { + devstarDomain: string | undefined, + terminal: vscode.Terminal + ): string { const baseUrl = `vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}`; const url = devstarDomain ? `${baseUrl}&devstar_domain=${devstarDomain}` : baseUrl; - // 检测本地系统类型和 PowerShell 版本 - try { - const localSystemInfo = await utils.detectLocalSystemInfo(); - console.log('本地系统检测结果:', localSystemInfo); + // 通过终端的 creationOptions 获取 shell 路径 + const shellPath = (terminal.creationOptions as any)?.shellPath || ''; + const isWindows = shellPath.toLowerCase().includes('powershell') || + shellPath.toLowerCase().includes('pwsh') || + shellPath.toLowerCase().includes('cmd'); - // 只有本地是 Windows 系统才使用 PowerShell 语法 - if (localSystemInfo.isWindows) { - // PowerShell 需要使用单引号包裹 URL,内部协议用双引号 - // 格式:code --new-window; code --open-url '"vscode://..."' - console.log('使用 PowerShell 语法(单引号嵌套双引号)'); - return `code --new-window; code --open-url '"${url}"'`; - } - } catch (error) { - console.log('检测本地系统失败,使用默认命令格式:', error); + if (isWindows) { + // PowerShell/CMD: 使用分号分隔,URL 需要特殊的引号处理 + console.log('检测到 Windows shell,使用 PowerShell 语法'); + return `code --new-window; code --open-url '"${url}"'`; + } else { + // Bash/Zsh: 使用 && 分隔,标准双引号 + console.log('检测到 Unix shell,使用 Bash 语法'); + return `code --new-window && code --open-url "${url}"`; } - - // 默认使用 && 语法(适用于 Linux/macOS) - console.log('使用默认命令语法 (&&)'); - return `code --new-window && code --open-url "${url}"`; } /** @@ -77,8 +74,8 @@ export default class RemoteContainer { devstarDomain = undefined; } - // 在本地终端实时检测命令格式 - const command = await this.buildOpenProjectCommand(host, hostname, port, username, path, devstarDomain); + // 根据终端类型生成对应的命令 + const command = this.buildOpenProjectCommand(host, hostname, port, username, path, devstarDomain, terminal); terminal.sendText(command); } else { vscode.window.showErrorMessage('无法创建终端,请检查终端是否可用。');