Compare commits

..

13 Commits

Author SHA1 Message Date
4c661ec06a Merge pull request '修复远程终端识别本地操作系统问题并完善工作流配置' (#7) from fix-bug into main
Some checks failed
CI/CD Pipeline for DevStar Extension / build (push) Failing after 8m20s
Reviewed-on: #7
2026-01-14 08:05:12 +00:00
872df0fd65 更新 .gitea/workflows/devstar-vscode-release.yaml
Some checks failed
CI/CD Pipeline for DevStar Extension / build (pull_request) Failing after 10s
2026-01-14 05:57:40 +00:00
505881edef 版本更新到0.5.3
Some checks failed
CI/CD Pipeline for DevStar Extension / build (pull_request) Failing after 13s
2026-01-14 03:56:16 +00:00
c5591f8936 找出正确的源分支并且添加skip ci 2026-01-14 03:37:37 +00:00
b7a73c4b15 修改推送到当前分支 2026-01-14 03:25:04 +00:00
4b74fa615a 在PR阶段递增版本号 2026-01-14 03:17:24 +00:00
devstar
07bb207ff3 chore: bump version to 0.5.2 [skip ci] 2026-01-13 13:23:38 +00:00
501a38b796 Merge pull request '针对shell路径判断方式进行优化' (#1) from fix-bug into main
Reviewed-on: http://192.168.10.4/yinxue/devstar-vscode/pulls/1
2026-01-13 12:42:20 +00:00
55c3bdfdfc 针对shell路径判断方式进行优化 2026-01-13 12:39:27 +00:00
5892abf513 删除掉不必要的内容 2026-01-13 05:36:05 +00:00
7dc0f11e6c 修改工作流分解版本后的方法&&优化配置用户信息 2026-01-13 05:22:34 +00:00
a2f474e1ca 使用具有绕过保护权限的PAT 2026-01-12 03:55:15 +00:00
7a19e09b1d 采用新开一个终端的方式判断系统和终端 2026-01-08 08:40:12 +00:00
5 changed files with 95 additions and 97 deletions

View File

@@ -13,12 +13,15 @@
"warn",
{
"selector": "import",
"format": [ "camelCase", "PascalCase" ]
"format": [
"camelCase",
"PascalCase"
]
}
],
"@typescript-eslint/semi": "warn",
"@typescript-eslint/semi": "off",
"curly": "warn",
"eqeqeq": "warn",
"eqeqeq": "off",
"no-throw-literal": "warn",
"semi": "off"
},

View File

@@ -23,8 +23,8 @@ jobs:
- name: 拉取代码
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
fetch-depth: 0
ref: ${{ github.head_ref }}
- name: 配置 Git
run: |
@@ -33,32 +33,51 @@ jobs:
git config --global --add safe.directory /github/workspace
# 配置用户信息
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "devstar"
git config --global user.email "devstar@noreply.devstar.cn"
- name: 自动递增版本号
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
- name: Check and bump version
if: github.event_name == 'pull_request'
run: |
apk add --no-cache jq
CURRENT_VERSION=$(jq -r '.version' package.json)
echo "当前版本: $CURRENT_VERSION"
# 获取远程 main 分支版本
git fetch origin main
MAIN_VERSION=$(git show origin/main:package.json | jq -r '.version')
PR_VERSION=$(jq -r '.version' package.json)
#版本
IFS='.' read -r MAJOR MINOR PATCH <<< "$CURRENT_VERSION"
echo "Main版本: $MAIN_VERSION"
echo "当前 PR 版本: $PR_VERSION"
# 递增补丁版本号
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
echo "新版本: $NEW_VERSION"
# 更新 package.json
jq --arg version "$NEW_VERSION" '.version = $version' package.json > package.json.tmp
mv package.json.tmp package.json
# 提交版本变更
git add package.json
git commit -m "chore: bump version to $NEW_VERSION [skip ci]"
git push
# 如果版本号相同,则递增
if [ "$MAIN_VERSION" = "$PR_VERSION" ]; then
echo "版本号未变更,开始递增..."
# 分解版本号
MAJOR=$(echo "$PR_VERSION" | cut -d'.' -f1)
MINOR=$(echo "$PR_VERSION" | cut -d'.' -f2)
PATCH=$(echo "$PR_VERSION" | cut -d'.' -f3)
# 递增补丁版本号
NEW_PATCH=$((PATCH + 1))
NEW_VERSION="$MAJOR.$MINOR.$NEW_PATCH"
echo "新版本: $NEW_VERSION"
# 更新 package.json
jq --arg version "$NEW_VERSION" '.version = $version' package.json > package.json.tmp
mv package.json.tmp package.json
# 提交版本变更
git config user.name "devstar-actions"
git config user.email "devstar-actions@devstar.cn"
git add package.json
git commit -m "chore: bump version to $NEW_VERSION [skip ci]"
# 推送到当前分支
BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)
git push origin $BRANCH_NAME || git push origin HEAD:refs/heads/$BRANCH_NAME
else
echo "版本号已更新,跳过递增"
fi
- name: 安装依赖
run: |
@@ -73,4 +92,4 @@ jobs:
run: |
npm run publish
env:
VSCE_PAT: ${{ secrets.VSCE_PAT }}
VSCE_PAT: ${{ secrets.VSCE_PAT }}

View File

@@ -2,7 +2,7 @@
"name": "devstar",
"displayName": "%displayName%",
"description": "%description%",
"version": "0.4.3",
"version": "0.5.3",
"keywords": [],
"publisher": "mengning",
"engines": {
@@ -42,6 +42,10 @@
{
"protocol": "vscode",
"path": "/openProject"
},
{
"protocol": "trae",
"path": "/openProject"
}
],
"views": {

View File

@@ -25,6 +25,46 @@ export default class RemoteContainer {
this.user = user;
}
/**
* 构建打开项目的命令
* 根据终端类型生成对应的命令
* 支持 Windows PowerShell/CMD 和 Linux/macOS Bash/Zsh
*/
private buildOpenProjectCommand(
host: string,
hostname: string,
port: number,
username: string,
path: string,
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;
// 获取本地操作系统类型
// 在远程环境下os.platform() 返回的是远程系统,但这里我们需要的是本地系统
// 所以通过终端的 shell 路径来推断
const shellPath = (terminal.creationOptions as any)?.shellPath || '';
console.log('终端 shell 路径:', shellPath);
// 检测 WindowsWindows shell 路径包含反斜杠或特定关键字)
const isWindows = shellPath.includes('\\') ||
shellPath.toLowerCase().includes('powershell') ||
shellPath.toLowerCase().includes('pwsh') ||
shellPath.toLowerCase().includes('cmd');
if (isWindows) {
// Windows PowerShell/CMD: 使用分号分隔URL 需要特殊的引号处理
console.log('检测到 Windows 本地系统,使用 PowerShell/CMD 语法');
return `code --new-window; code --open-url '"${url}"'`;
} else {
// macOS/Linux: 使用 && 分隔,标准双引号
console.log('检测到 Unix 本地系统macOS/Linux使用 Bash/Zsh 语法');
return `code --new-window && code --open-url "${url}"`;
}
}
/**
* 第一次打开远程项目
*/
@@ -40,29 +80,8 @@ export default class RemoteContainer {
devstarDomain = undefined;
}
const semver = require('semver');
const powershellVersion = context.globalState.get('powershellVersion');
const powershell_semver_compatible_version = semver.coerce(powershellVersion);
let command = '';
if (devstarDomain === undefined) {
if (powershellVersion === undefined) {
command = `code --new-window && code --open-url "vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}"`;
} else if (semver.satisfies(powershell_semver_compatible_version, ">=5.1.26100")) {
command = `code --new-window ; code --% --open-url "vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}"`;
} else {
command = `code --new-window && code --open-url "vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}"`;
}
} else {
if (powershellVersion === undefined) {
command = `code --new-window && code --open-url "vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}&devstar_domain=${devstarDomain}"`;
} else if (semver.satisfies(powershell_semver_compatible_version, ">=5.1.26100")) {
command = `code --new-window ; code --% --open-url "vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}&devstar_domain=${devstarDomain}"`;
} else {
command = `code --new-window && code --open-url "vscode://mengning.devstar/openProjectSkippingLoginCheck?host=${host}&hostname=${hostname}&port=${port}&username=${username}&path=${path}&devstar_domain=${devstarDomain}"`;
}
}
// 根据终端类型生成对应的命令
const command = this.buildOpenProjectCommand(host, hostname, port, username, path, devstarDomain, terminal);
terminal.sendText(command);
} else {
vscode.window.showErrorMessage('无法创建终端,请检查终端是否可用。');
@@ -276,18 +295,6 @@ export default class RemoteContainer {
reject(error);
});
// 由于使用了 stdio: 'ignore',这些事件监听器不再需要
// sshProcess.stdout.on('data', (data: Buffer) => {
// console.log(`[SSH stdout] ${data.toString()}`);
// });
// sshProcess.stderr.on('data', (data: Buffer) => {
// console.error(`[SSH stderr] ${data.toString()}`);
// });
// 注意:由于进程已 detached 和 unref不再需要保存到 sshProcesses Map
// 因为我们无法也不需要控制这些独立进程的生命周期
// 等待 SSH 连接建立
setTimeout(() => {
resolve();

View File

@@ -1,12 +1,7 @@
import * as http from 'http';
import * as https from 'https';
import * as vscode from 'vscode';
import * as os from 'os';
import { exec } from 'child_process';
const {
generateKeyPairSync,
} = require('node:crypto')
const axios = require('axios');
const cheerio = require('cheerio');
@@ -23,36 +18,6 @@ export function isMacOS(): boolean {
return os.platform() === 'darwin';
}
export function fetch(url: string): Promise<string> {
// determine the library to use (based on the url protocol)
const lib = url.startsWith('https://') ? https : http;
return new Promise((resolve, reject) => {
lib.get(url, (response) => {
// make sure the status code is 200
if (response.statusCode !== 200) {
reject(new Error(`Failed to load page, status code: ${response.statusCode}`));
return;
}
let data = '';
response.on('data', (chunk) => {
data += chunk;
});
response.on('end', () => {
resolve(data);
});
}).on('error', (err) => {
reject(err);
});
});
}
export const Sleep = (ms: number) => {
return new Promise(resolve => setTimeout(resolve, ms))
}
export async function getVsCodeCommitId(): Promise<string> {
if (isLinux() || isMacOS()) {
return new Promise<string>((resolve) => {