@linxin666/dsh-ssh 0.3.3 → 0.3.4

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/lib/client.js CHANGED
@@ -15982,7 +15982,7 @@ window.__ModuleLoader__.load({
15982
15982
  /** The building package's version, when the bundle carries it. */
15983
15983
  function bakedVersion() {
15984
15984
  try {
15985
- return "0.3.3";
15985
+ return "0.3.4";
15986
15986
  } catch {
15987
15987
  return;
15988
15988
  }
package/lib/index.js CHANGED
@@ -3,6 +3,7 @@ import { closeSync, createReadStream, createWriteStream, existsSync, lstatSync,
3
3
  import { Client } from "ssh2";
4
4
  import { homedir, tmpdir } from "node:os";
5
5
  import { basename, dirname, isAbsolute, join, relative, resolve } from "node:path";
6
+ import { isAbsolute as isAbsolute$1, join as join$1 } from "node:path/posix";
6
7
  import { createServer } from "node:net";
7
8
  import { unlink } from "node:fs/promises";
8
9
  import { randomBytes } from "node:crypto";
@@ -1031,8 +1032,9 @@ var import_lib = /* @__PURE__ */ __toESM((/* @__PURE__ */ __commonJSMin(((export
1031
1032
  */
1032
1033
  /** Expand a leading ~ (or ~user) in a path, platform-style. */
1033
1034
  function expandHome$1(path, home = homedir()) {
1035
+ const j = home.startsWith("/") ? join$1 : join;
1034
1036
  if (path === "~") return home;
1035
- if (path.startsWith("~/") || path.startsWith("~\\")) return join(home, path.slice(2));
1037
+ if (path.startsWith("~/") || path.startsWith("~\\")) return j(home, path.slice(2));
1036
1038
  return path;
1037
1039
  }
1038
1040
  /**
@@ -1042,12 +1044,15 @@ function expandHome$1(path, home = homedir()) {
1042
1044
  * @returns the absolute DSH home path.
1043
1045
  */
1044
1046
  function resolveDshHome(env = process.env, home = homedir()) {
1047
+ const isPosix = home.startsWith("/");
1048
+ const j = isPosix ? join$1 : join;
1049
+ const isAbs = isPosix ? isAbsolute$1 : isAbsolute;
1045
1050
  const raw = env.DSH_HOME;
1046
1051
  if (raw !== void 0 && raw.trim() !== "") {
1047
1052
  const expanded = expandHome$1(raw.trim(), home);
1048
- return isAbsolute(expanded) ? expanded : join(process.cwd(), expanded);
1053
+ return isAbs(expanded) ? expanded : j(process.cwd(), expanded);
1049
1054
  }
1050
- return join(home, ".dsh");
1055
+ return j(home, ".dsh");
1051
1056
  }
1052
1057
  /** Resolve the DSH home directory from the live environment. */
1053
1058
  function dshHome() {
@@ -1773,7 +1778,7 @@ function walkLocalDir(root) {
1773
1778
  const stat = lstatSync(full);
1774
1779
  if (stat.isSymbolicLink()) continue;
1775
1780
  if (stat.isDirectory()) visit(full);
1776
- else if (stat.isFile()) files.push(relative(root, full));
1781
+ else if (stat.isFile()) files.push(relative(root, full).replaceAll("\\", "/"));
1777
1782
  }
1778
1783
  };
1779
1784
  visit(root);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-ssh",
3
3
  "description": "Remote SSH operations for the dsh web GUI: host config store (~/.dsh/dsh-ssh.json, import from ~/.ssh/config), a persistent ssh2 connection pool with jump-host support, exec / PTY web terminal / SFTP transfer / local port-forward tunnels / cluster execution, plus agent tools (ssh_list, ssh_exec, ssh_upload, ssh_download, ssh_tunnel, ssh_cluster). Hot-pluggable — mounted via ~/.dsh/cordis.patch.yml + a profile node_modules symlink, no dsh source changes.",
4
- "version": "0.3.3",
4
+ "version": "0.3.4",
5
5
  "type": "module",
6
6
  "engines": {
7
7
  "node": "^22.19.0 || >=24.0.0"
package/src/dsh-home.ts CHANGED
@@ -7,11 +7,14 @@
7
7
 
8
8
  import { homedir } from 'node:os'
9
9
  import { isAbsolute, join } from 'node:path'
10
+ import { isAbsolute as posixIsAbsolute, join as posixJoin } from 'node:path/posix'
10
11
 
11
12
  /** Expand a leading ~ (or ~user) in a path, platform-style. */
12
13
  export function expandHome(path: string, home: string = homedir()): string {
14
+ const isPosix = home.startsWith('/')
15
+ const j = isPosix ? posixJoin : join
13
16
  if (path === '~') return home
14
- if (path.startsWith('~/') || path.startsWith('~\\')) return join(home, path.slice(2))
17
+ if (path.startsWith('~/') || path.startsWith('~\\')) return j(home, path.slice(2))
15
18
  return path
16
19
  }
17
20
 
@@ -22,12 +25,15 @@ export function expandHome(path: string, home: string = homedir()): string {
22
25
  * @returns the absolute DSH home path.
23
26
  */
24
27
  export function resolveDshHome(env: NodeJS.ProcessEnv = process.env, home: string = homedir()): string {
28
+ const isPosix = home.startsWith('/')
29
+ const j = isPosix ? posixJoin : join
30
+ const isAbs = isPosix ? posixIsAbsolute : isAbsolute
25
31
  const raw = env.DSH_HOME
26
32
  if (raw !== undefined && raw.trim() !== '') {
27
33
  const expanded = expandHome(raw.trim(), home)
28
- return isAbsolute(expanded) ? expanded : join(process.cwd(), expanded)
34
+ return isAbs(expanded) ? expanded : j(process.cwd(), expanded)
29
35
  }
30
- return join(home, '.dsh')
36
+ return j(home, '.dsh')
31
37
  }
32
38
 
33
39
  /** Resolve the DSH home directory from the live environment. */
@@ -22,7 +22,7 @@ export function walkLocalDir(root: string): string[] {
22
22
  const stat = lstatSync(full)
23
23
  if (stat.isSymbolicLink()) continue
24
24
  if (stat.isDirectory()) visit(full)
25
- else if (stat.isFile()) files.push(relative(root, full))
25
+ else if (stat.isFile()) files.push(relative(root, full).replaceAll('\\', '/'))
26
26
  }
27
27
  }
28
28
  visit(root)