@zhangfengshun/dsh-remote-ssh 1.9.1 → 1.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  本文件的版本号与 `package.json` 的 `version` 保持一致。每个版本对应一个 Cordis Package 快照(`pkg-N`)。
4
4
 
5
+ ## [1.9.3] — 修复 syncDown 删除 .remote-ssh.json 导致终端不工作
6
+ ### 修复
7
+ - **`remoteSyncDown` 会清空镜像目录**:syncDown 先 `rm -rf` 镜像目录再 `tar xf` 展开,导致之前写入的 `.remote-ssh.json`(供 shell wrapper 读取连接信息)被删掉,终端 wrapper 检测不到远程工作区,降级到本地 shell。
8
+ - **修复**:在 `createRemoteWorkspace`、`syncDown` API、`remote_ssh_sync` 工具三处,都在 `remoteSyncDown` 完成后重新写入 `.remote-ssh.json`。
9
+ - 已为现有工作区补写 `.remote-ssh.json`(无需重新创建工作区)。
10
+
11
+ ## [1.9.2] — 修复自动配置 patch 不生效(bundles 顺序)
12
+ ### 修复
13
+ - **config 覆盖被跳过**:`cordis.patch.yml` 中的 `id: better-sidebar` config 覆盖需要在 `better-sidebar` 条目被 insert 之后才能生效。如果 `@zhangfengshun/dsh-remote-ssh` 在 bundles 列表中排在 `dsh-better-sidebar` 之前,patch 会因"entry not found"被跳过。
14
+ - **修复方式**:在 README 中明确要求安装顺序(`@zhangfengshun/dsh-remote-ssh` 必须在 `dsh-better-sidebar` 之后),并提供手动调整 `profile/package.json` 中 `dsh.profile.bundles` 顺序的说明。
15
+
5
16
  ## [1.9.1] — 安装时自动配置 better-sidebar shell
6
17
  ### 改进
7
18
  - **安装即生效**:`cordis.patch.yml` 新增 `id: better-sidebar` 的 `config.shell` 覆盖,用 `!!js` 动态计算 wrapper 脚本路径(适配不同平台和用户主目录)。安装插件后无需手动编辑任何配置文件,重启 DSH 即可使用远程终端透明接入。
package/README.md CHANGED
@@ -29,10 +29,12 @@ dsh plugin --profile <name> add /absolute/path/to/dsh-remote-ssh
29
29
  ### 发布后安装
30
30
 
31
31
  ```bash
32
- dsh plugin --profile <name> add @zhangfengshun/dsh-remote-ssh@1.9.1
32
+ dsh plugin --profile <name> add @zhangfengshun/dsh-remote-ssh@1.9.3
33
33
  ```
34
34
 
35
35
  > ⚠️ 安装后需**重启 DSH** 才生效;后续仅修改 Client 半边时刷新浏览器即可。
36
+ >
37
+ > ⚠️ **安装顺序**:本插件会自动覆盖 `dsh-better-sidebar` 的 `shell` 配置。为确保 patch 生效(config 覆盖在 insert 之后应用),`@zhangfengshun/dsh-remote-ssh` 必须在 bundles 列表中排在 `dsh-better-sidebar` **之后**。如果先安装了 `@zhangfengshun/dsh-remote-ssh`,再安装 `dsh-better-sidebar`,需手动调整 `profile/package.json` 中 `dsh.profile.bundles` 的顺序,把 `@zhangfengshun/dsh-remote-ssh` 移到最后。
36
38
 
37
39
  ## 快速开始
38
40
 
package/cordis.patch.yml CHANGED
@@ -13,9 +13,10 @@
13
13
  - id: better-sidebar
14
14
  config:
15
15
  shell: !!js |
16
- var os = require('os');
17
- var path = require('path');
18
- var dir = path.join(os.homedir(), '.dsh', 'remote-ssh');
19
- var isWin = process.platform === 'win32';
20
- var wrapper = isWin ? path.join(dir, 'dsh-remote-shell.cmd') : path.join(dir, 'dsh-remote-shell');
21
- return wrapper;
16
+ (() => {
17
+ var homedir = process.env.USERPROFILE || process.env.HOME || process.env.HOMEDRIVE + process.env.HOMEPATH;
18
+ var isWin = process.platform === 'win32';
19
+ var sep = isWin ? '\\' : '/';
20
+ var dir = homedir + sep + '.dsh' + sep + 'remote-ssh';
21
+ return isWin ? dir + sep + 'dsh-remote-shell.cmd' : dir + sep + 'dsh-remote-shell';
22
+ })()
package/lib/index.js CHANGED
@@ -819,7 +819,13 @@ function apply(ctx, config) {
819
819
  try {
820
820
  await writeFile(join(mirrorDir, "README.md"), remoteWorkspaceReadme(p.name, a.remotePath), "utf8");
821
821
  } catch (e) {}
822
+ // 自动同步:把远程文件拉到本地镜像,使内置「文件」页签可见真实远程文件。
823
+ // 注意:remoteSyncDown 会先清空镜像目录,所以 .remote-ssh.json 必须在同步之后写。
824
+ try {
825
+ await remoteSyncDown(subprocess, p, a.remotePath, mirrorDir);
826
+ } catch (e) {}
822
827
  // 写 .remote-ssh.json:供 shell wrapper 读取连接信息(仅密钥认证,不含密码)。
828
+ // 必须在 remoteSyncDown 之后写,否则会被同步过程清空。
823
829
  try {
824
830
  const connInfo = {
825
831
  profileId: p.id, host: p.host, port: p.port || 22, user: p.user,
@@ -827,10 +833,6 @@ function apply(ctx, config) {
827
833
  };
828
834
  await writeFile(join(mirrorDir, ".remote-ssh.json"), JSON.stringify(connInfo, null, 2), "utf8");
829
835
  } catch (e) {}
830
- // 自动同步:把远程文件拉到本地镜像,使内置「文件」页签可见真实远程文件。
831
- try {
832
- await remoteSyncDown(subprocess, p, a.remotePath, mirrorDir);
833
- } catch (e) {}
834
836
  let workspaceId = null;
835
837
  if (workspaceRegistry) {
836
838
  try {
@@ -936,7 +938,18 @@ function apply(ctx, config) {
936
938
  if (!ws) return { ok: false, error: "未找到远程工作区" };
937
939
  const p = getProfile(ws.profileId);
938
940
  if (!p) return { ok: false, error: "未找到连接配置" };
939
- return await remoteSyncDown(subprocess, p, ws.remotePath, ws.mirrorPath);
941
+ const r = await remoteSyncDown(subprocess, p, ws.remotePath, ws.mirrorPath);
942
+ // remoteSyncDown 会清空镜像目录,需要重新写入 .remote-ssh.json
943
+ if (r.ok) {
944
+ try {
945
+ const connInfo = {
946
+ profileId: p.id, host: p.host, port: p.port || 22, user: p.user,
947
+ keyPath: p.keyPath || "", proxyJump: p.proxyJump || "", remotePath: ws.remotePath
948
+ };
949
+ await writeFile(join(ws.mirrorPath, ".remote-ssh.json"), JSON.stringify(connInfo, null, 2), "utf8");
950
+ } catch (e) {}
951
+ }
952
+ return r;
940
953
  },
941
954
  /** 本地镜像 → 远端(按工作区)。 */
942
955
  syncUp: async (args) => {
@@ -1168,7 +1181,18 @@ function apply(ctx, config) {
1168
1181
  if (!ws) return { ok: false, error: "未找到远程工作区(workspaceId 必填,或当前会话非远程工作区)" };
1169
1182
  const p = getProfile(ws.profileId);
1170
1183
  if (!p) return { ok: false, error: "未找到连接配置" };
1171
- return await remoteSyncDown(subprocess, p, ws.remotePath, ws.mirrorPath);
1184
+ const r = await remoteSyncDown(subprocess, p, ws.remotePath, ws.mirrorPath);
1185
+ // remoteSyncDown 会清空镜像目录,需要重新写入 .remote-ssh.json
1186
+ if (r.ok) {
1187
+ try {
1188
+ const connInfo = {
1189
+ profileId: p.id, host: p.host, port: p.port || 22, user: p.user,
1190
+ keyPath: p.keyPath || "", proxyJump: p.proxyJump || "", remotePath: ws.remotePath
1191
+ };
1192
+ await writeFile(join(ws.mirrorPath, ".remote-ssh.json"), JSON.stringify(connInfo, null, 2), "utf8");
1193
+ } catch (e) {}
1194
+ }
1195
+ return r;
1172
1196
  }
1173
1197
  });
1174
1198
  register({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhangfengshun/dsh-remote-ssh",
3
- "version": "1.9.1",
3
+ "version": "1.9.3",
4
4
  "description": "DSH web plugin: VSCode Remote-SSH-like remote development (SSH to supercomputers/servers, remote workspace, file explorer, integrated terminal), integrated with dsh-better-sidebar and DSH settings.",
5
5
  "keywords": [
6
6
  "dsh",