dsh-remote 0.8.92 → 0.8.93
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/LICENSE +21 -21
- package/README.en.md +369 -369
- package/README.md +354 -354
- package/cordis.patch.yml +9 -9
- package/lib/audit.js +45 -45
- package/lib/binding.js +172 -172
- package/lib/client.js +4647 -4647
- package/lib/credential.js +270 -270
- package/lib/errors.js +141 -141
- package/lib/exec-job.js +242 -242
- package/lib/file-reference.js +457 -457
- package/lib/forwards.js +258 -258
- package/lib/host-api.js +822 -822
- package/lib/hostkey.js +108 -108
- package/lib/http-transport.js +201 -201
- package/lib/ignore.js +202 -202
- package/lib/index.js +4488 -4488
- package/lib/instructions-dynamic.js +415 -415
- package/lib/instructions.js +288 -288
- package/lib/open-folder.js +56 -56
- package/lib/openssh.js +940 -940
- package/lib/paths.js +292 -292
- package/lib/pool.js +1029 -1029
- package/lib/posix-shell.cjs +34 -34
- package/lib/registry.js +296 -296
- package/lib/remote-fs.js +173 -173
- package/lib/remote-sandbox.js +183 -183
- package/lib/remote-shell-child.cjs +397 -397
- package/lib/remote-shell.js +697 -697
- package/lib/remote-skills.js +312 -312
- package/lib/routes-audit.js +58 -58
- package/lib/routes-forwards.js +72 -72
- package/lib/routes-fs.js +251 -251
- package/lib/routes-machines.js +186 -186
- package/lib/routes-misc.js +187 -187
- package/lib/routes-term.js +169 -169
- package/lib/routes-update.js +143 -143
- package/lib/routes-web-attach.js +112 -112
- package/lib/routes-workspace.js +312 -312
- package/lib/search.js +235 -235
- package/lib/sftp-surface.js +119 -119
- package/lib/sshconfig.js +779 -779
- package/lib/sync.js +350 -350
- package/lib/tasks.js +95 -95
- package/lib/telemetry.js +247 -247
- package/lib/terminal.js +205 -205
- package/lib/tui/flow.js +130 -130
- package/lib/tui/format.js +380 -380
- package/lib/tui/i18n.js +350 -350
- package/lib/tui/index.js +531 -531
- package/lib/tui/provider.js +344 -344
- package/lib/tui/scene.js +986 -986
- package/lib/update.js +490 -472
- package/lib/web-attach.js +860 -860
- package/lib/workspace-cleanup.js +337 -337
- package/package.json +103 -103
package/lib/open-folder.js
CHANGED
|
@@ -1,56 +1,56 @@
|
|
|
1
|
-
// 在系统默认文件管理器里打开一个本地目录。
|
|
2
|
-
//
|
|
3
|
-
// 插件跑在 dsh-tui 进程里,所以“打开本机文件夹”就是一个本地动作:
|
|
4
|
-
// · macOS → `open <dir>`
|
|
5
|
-
// · Windows → `explorer <dir>`
|
|
6
|
-
// · 其它 → `xdg-open <dir>`
|
|
7
|
-
// 只做一次 spawn,不读输出、不等待、不阻塞;spawn 的异步 `error` 必须被吃掉,
|
|
8
|
-
// 否则一个不存在的 `xdg-open` 会以未处理事件把宿主进程带崩。
|
|
9
|
-
|
|
10
|
-
import { spawn } from 'node:child_process'
|
|
11
|
-
|
|
12
|
-
/** 当前平台对应的“打开文件夹”命令。 */
|
|
13
|
-
export function folderOpenCommand(platform = process.platform) {
|
|
14
|
-
if (platform === 'darwin') return 'open'
|
|
15
|
-
if (platform === 'win32') return 'explorer'
|
|
16
|
-
return 'xdg-open'
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* 用系统默认文件管理器打开 `target`。
|
|
21
|
-
*
|
|
22
|
-
* 返回的 Promise 在子进程真的 spawn 成功时 resolve、spawn 失败(如 Linux 没有
|
|
23
|
-
* `xdg-open`、权限不足)时 reject —— 调用方不能先报“已打开”再吞掉失败。
|
|
24
|
-
* 子进程本身仍然 detached + ignore,且从不 await 退出码:`explorer` 对目录参数
|
|
25
|
-
* 返回非零退出码是常态。
|
|
26
|
-
*
|
|
27
|
-
* @param {string} target - 本地绝对路径。
|
|
28
|
-
* @param {object} [options]
|
|
29
|
-
* @param {string} [options.platform] - 覆盖平台(测试用)。
|
|
30
|
-
* @param {Function} [options.spawnImpl] - 覆盖 spawn(测试用)。
|
|
31
|
-
* @returns {Promise<string>} resolve 实际使用的命令名。
|
|
32
|
-
*/
|
|
33
|
-
export function openLocalFolder(target, options = {}) {
|
|
34
|
-
const platform = options.platform || process.platform
|
|
35
|
-
const spawnImpl = typeof options.spawnImpl === 'function' ? options.spawnImpl : spawn
|
|
36
|
-
const directory = String(target == null ? '' : target)
|
|
37
|
-
if (!directory) return Promise.reject(new Error('openLocalFolder: target is required'))
|
|
38
|
-
const command = folderOpenCommand(platform)
|
|
39
|
-
return new Promise((resolve, reject) => {
|
|
40
|
-
let child
|
|
41
|
-
try {
|
|
42
|
-
child = spawnImpl(command, [directory], { detached: true, stdio: 'ignore' })
|
|
43
|
-
} catch (error) {
|
|
44
|
-
reject(error)
|
|
45
|
-
return
|
|
46
|
-
}
|
|
47
|
-
if (!child || typeof child.on !== 'function') {
|
|
48
|
-
// 极小化的 spawn 替身:没有事件可等,按成功处理。
|
|
49
|
-
resolve(command)
|
|
50
|
-
return
|
|
51
|
-
}
|
|
52
|
-
child.on('spawn', () => resolve(command))
|
|
53
|
-
child.on('error', reject)
|
|
54
|
-
if (typeof child.unref === 'function') child.unref()
|
|
55
|
-
})
|
|
56
|
-
}
|
|
1
|
+
// 在系统默认文件管理器里打开一个本地目录。
|
|
2
|
+
//
|
|
3
|
+
// 插件跑在 dsh-tui 进程里,所以“打开本机文件夹”就是一个本地动作:
|
|
4
|
+
// · macOS → `open <dir>`
|
|
5
|
+
// · Windows → `explorer <dir>`
|
|
6
|
+
// · 其它 → `xdg-open <dir>`
|
|
7
|
+
// 只做一次 spawn,不读输出、不等待、不阻塞;spawn 的异步 `error` 必须被吃掉,
|
|
8
|
+
// 否则一个不存在的 `xdg-open` 会以未处理事件把宿主进程带崩。
|
|
9
|
+
|
|
10
|
+
import { spawn } from 'node:child_process'
|
|
11
|
+
|
|
12
|
+
/** 当前平台对应的“打开文件夹”命令。 */
|
|
13
|
+
export function folderOpenCommand(platform = process.platform) {
|
|
14
|
+
if (platform === 'darwin') return 'open'
|
|
15
|
+
if (platform === 'win32') return 'explorer'
|
|
16
|
+
return 'xdg-open'
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 用系统默认文件管理器打开 `target`。
|
|
21
|
+
*
|
|
22
|
+
* 返回的 Promise 在子进程真的 spawn 成功时 resolve、spawn 失败(如 Linux 没有
|
|
23
|
+
* `xdg-open`、权限不足)时 reject —— 调用方不能先报“已打开”再吞掉失败。
|
|
24
|
+
* 子进程本身仍然 detached + ignore,且从不 await 退出码:`explorer` 对目录参数
|
|
25
|
+
* 返回非零退出码是常态。
|
|
26
|
+
*
|
|
27
|
+
* @param {string} target - 本地绝对路径。
|
|
28
|
+
* @param {object} [options]
|
|
29
|
+
* @param {string} [options.platform] - 覆盖平台(测试用)。
|
|
30
|
+
* @param {Function} [options.spawnImpl] - 覆盖 spawn(测试用)。
|
|
31
|
+
* @returns {Promise<string>} resolve 实际使用的命令名。
|
|
32
|
+
*/
|
|
33
|
+
export function openLocalFolder(target, options = {}) {
|
|
34
|
+
const platform = options.platform || process.platform
|
|
35
|
+
const spawnImpl = typeof options.spawnImpl === 'function' ? options.spawnImpl : spawn
|
|
36
|
+
const directory = String(target == null ? '' : target)
|
|
37
|
+
if (!directory) return Promise.reject(new Error('openLocalFolder: target is required'))
|
|
38
|
+
const command = folderOpenCommand(platform)
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
let child
|
|
41
|
+
try {
|
|
42
|
+
child = spawnImpl(command, [directory], { detached: true, stdio: 'ignore' })
|
|
43
|
+
} catch (error) {
|
|
44
|
+
reject(error)
|
|
45
|
+
return
|
|
46
|
+
}
|
|
47
|
+
if (!child || typeof child.on !== 'function') {
|
|
48
|
+
// 极小化的 spawn 替身:没有事件可等,按成功处理。
|
|
49
|
+
resolve(command)
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
child.on('spawn', () => resolve(command))
|
|
53
|
+
child.on('error', reject)
|
|
54
|
+
if (typeof child.unref === 'function') child.unref()
|
|
55
|
+
})
|
|
56
|
+
}
|