tmex-cli 0.2.4 → 0.2.6
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/dist/runtime/server.js +31 -10
- package/package.json +1 -1
package/dist/runtime/server.js
CHANGED
|
@@ -20282,7 +20282,7 @@ var require_lib3 = __commonJS((exports, module) => {
|
|
|
20282
20282
|
|
|
20283
20283
|
// src/runtime/server.ts
|
|
20284
20284
|
import { existsSync as existsSync3 } from "fs";
|
|
20285
|
-
import { extname, join as
|
|
20285
|
+
import { extname, join as join3, normalize, resolve as resolve2, sep } from "path";
|
|
20286
20286
|
|
|
20287
20287
|
// ../../apps/gateway/src/crypto/errors.ts
|
|
20288
20288
|
function contextLabel(context) {
|
|
@@ -51869,6 +51869,7 @@ import { homedir } from "os";
|
|
|
51869
51869
|
|
|
51870
51870
|
// ../../apps/gateway/src/tmux/local-shell-path.ts
|
|
51871
51871
|
import { existsSync } from "fs";
|
|
51872
|
+
import { delimiter, join as join2 } from "path";
|
|
51872
51873
|
var SHELL_ENV_BEGIN_MARKER = "__TMEX_SHELL_ENV_BEGIN__";
|
|
51873
51874
|
var SHELL_ENV_END_MARKER = "__TMEX_SHELL_ENV_END__";
|
|
51874
51875
|
var SHELL_ENV_PROBE_COMMAND = `printf '${SHELL_ENV_BEGIN_MARKER}\\n'; /usr/bin/env; printf '${SHELL_ENV_END_MARKER}\\n'`;
|
|
@@ -51938,23 +51939,40 @@ function extractPathFromShellEnv(stdout) {
|
|
|
51938
51939
|
}
|
|
51939
51940
|
return null;
|
|
51940
51941
|
}
|
|
51942
|
+
function canResolveExecutableFromPath(resolvedPath, executableName, deps) {
|
|
51943
|
+
for (const rawDir of resolvedPath.split(delimiter)) {
|
|
51944
|
+
const dir2 = rawDir.trim();
|
|
51945
|
+
if (!dir2) {
|
|
51946
|
+
continue;
|
|
51947
|
+
}
|
|
51948
|
+
if (deps.fileExists(join2(dir2, executableName))) {
|
|
51949
|
+
return true;
|
|
51950
|
+
}
|
|
51951
|
+
}
|
|
51952
|
+
return false;
|
|
51953
|
+
}
|
|
51941
51954
|
function probeShellPath(shellPath, deps) {
|
|
51942
51955
|
const attempts = [
|
|
51943
51956
|
[shellPath, "-l", "-c", SHELL_ENV_PROBE_COMMAND],
|
|
51944
51957
|
[shellPath, "-l", "-i", "-c", SHELL_ENV_PROBE_COMMAND],
|
|
51945
51958
|
[shellPath, "-c", SHELL_ENV_PROBE_COMMAND]
|
|
51946
51959
|
];
|
|
51960
|
+
let fallbackPath = null;
|
|
51947
51961
|
for (const cmd of attempts) {
|
|
51948
51962
|
const result = deps.runSync(cmd);
|
|
51949
51963
|
if (result.exitCode !== 0) {
|
|
51950
51964
|
continue;
|
|
51951
51965
|
}
|
|
51952
51966
|
const resolvedPath = extractPathFromShellEnv(result.stdout);
|
|
51953
|
-
if (resolvedPath) {
|
|
51967
|
+
if (!resolvedPath) {
|
|
51968
|
+
continue;
|
|
51969
|
+
}
|
|
51970
|
+
fallbackPath ??= resolvedPath;
|
|
51971
|
+
if (canResolveExecutableFromPath(resolvedPath, "tmux", deps)) {
|
|
51954
51972
|
return resolvedPath;
|
|
51955
51973
|
}
|
|
51956
51974
|
}
|
|
51957
|
-
return
|
|
51975
|
+
return fallbackPath;
|
|
51958
51976
|
}
|
|
51959
51977
|
function createLocalShellPathCache(input = {}) {
|
|
51960
51978
|
const deps = {
|
|
@@ -51991,13 +52009,16 @@ function getLocalShellPath() {
|
|
|
51991
52009
|
return defaultLocalShellPathCache.get();
|
|
51992
52010
|
}
|
|
51993
52011
|
function buildLocalTmuxEnv(resolvedPath, baseEnv = process.env) {
|
|
51994
|
-
|
|
51995
|
-
|
|
51996
|
-
}
|
|
51997
|
-
return {
|
|
51998
|
-
...baseEnv,
|
|
51999
|
-
PATH: resolvedPath
|
|
52012
|
+
const nextEnv = {
|
|
52013
|
+
...baseEnv
|
|
52000
52014
|
};
|
|
52015
|
+
if (resolvedPath) {
|
|
52016
|
+
nextEnv.PATH = resolvedPath;
|
|
52017
|
+
}
|
|
52018
|
+
if (!nextEnv.LC_CTYPE && !nextEnv.LC_ALL && !nextEnv.LANG) {
|
|
52019
|
+
nextEnv.LC_CTYPE = "en_US.UTF-8";
|
|
52020
|
+
}
|
|
52021
|
+
return nextEnv;
|
|
52001
52022
|
}
|
|
52002
52023
|
|
|
52003
52024
|
// ../../apps/gateway/src/tmux/ssh-auth.ts
|
|
@@ -55758,7 +55779,7 @@ async function serveFrontend(req, staticRoot) {
|
|
|
55758
55779
|
if (!requestedPath) {
|
|
55759
55780
|
return new Response(t3("runtime.forbidden"), { status: 403 });
|
|
55760
55781
|
}
|
|
55761
|
-
const indexPath =
|
|
55782
|
+
const indexPath = join3(staticRoot, "index.html");
|
|
55762
55783
|
const targetPath = existsSync3(requestedPath) ? requestedPath : indexPath;
|
|
55763
55784
|
if (!existsSync3(targetPath)) {
|
|
55764
55785
|
return new Response(t3("runtime.frontendMissing"), { status: 500 });
|