litmus-cli 1.4.35 → 1.4.37
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/README.md +28 -2
- package/dist/commands/connect.d.ts +59 -4
- package/dist/commands/connect.d.ts.map +1 -1
- package/dist/commands/connect.js +137 -12
- package/dist/commands/connect.js.map +1 -1
- package/dist/commands/init.d.ts.map +1 -1
- package/dist/commands/init.js +3 -2
- package/dist/commands/init.js.map +1 -1
- package/dist/lib/ai-tracking.d.ts +5 -0
- package/dist/lib/ai-tracking.d.ts.map +1 -1
- package/dist/lib/ai-tracking.js +24 -9
- package/dist/lib/ai-tracking.js.map +1 -1
- package/dist/lib/api.d.ts.map +1 -1
- package/dist/lib/api.js +6 -5
- package/dist/lib/api.js.map +1 -1
- package/dist/lib/backfill-tools.d.ts +37 -1
- package/dist/lib/backfill-tools.d.ts.map +1 -1
- package/dist/lib/backfill-tools.js +63 -12
- package/dist/lib/backfill-tools.js.map +1 -1
- package/dist/lib/capture-selftest.d.ts +7 -2
- package/dist/lib/capture-selftest.d.ts.map +1 -1
- package/dist/lib/capture-selftest.js +4 -4
- package/dist/lib/capture-selftest.js.map +1 -1
- package/dist/lib/cursor-restart.js +1 -1
- package/dist/lib/cursor-restart.js.map +1 -1
- package/dist/lib/detection.d.ts +75 -11
- package/dist/lib/detection.d.ts.map +1 -1
- package/dist/lib/detection.js +259 -33
- package/dist/lib/detection.js.map +1 -1
- package/dist/lib/hook-logger.cjs +57 -60
- package/dist/lib/platform.d.ts +19 -6
- package/dist/lib/platform.d.ts.map +1 -1
- package/dist/lib/platform.js +40 -9
- package/dist/lib/platform.js.map +1 -1
- package/dist/lib/ssh-client.d.ts +64 -0
- package/dist/lib/ssh-client.d.ts.map +1 -0
- package/dist/lib/ssh-client.js +128 -0
- package/dist/lib/ssh-client.js.map +1 -0
- package/dist/lib/watcher.js +4 -41
- package/dist/lib/watcher.js.map +1 -1
- package/dist/lib/wsl.d.ts +49 -0
- package/dist/lib/wsl.d.ts.map +1 -0
- package/dist/lib/wsl.js +99 -0
- package/dist/lib/wsl.js.map +1 -0
- package/package.json +1 -1
package/dist/lib/wsl.js
ADDED
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import os from "os";
|
|
2
|
+
import path from "path";
|
|
3
|
+
import { accessSync, constants, realpathSync, statSync } from "fs";
|
|
4
|
+
/**
|
|
5
|
+
* ENG-2683 — `litmus connect` run inside WSL, driving an editor that lives on Windows.
|
|
6
|
+
*
|
|
7
|
+
* Inside WSL the CLI is a Linux process, so it writes the key and the `Host litmus-…`
|
|
8
|
+
* block into WSL's own `~/.ssh`. But the `code` or `cursor` on a WSL PATH is normally the
|
|
9
|
+
* WINDOWS editor's shim, mounted under `/mnt/c/…`, and Remote-SSH runs in that Windows
|
|
10
|
+
* editor with Windows' ssh and `C:\Users\<name>\.ssh\config` — a file with no such host.
|
|
11
|
+
* The connect then fails in the editor ("Could not resolve hostname litmus-…") with
|
|
12
|
+
* nothing on our side to show for it. So `connect` recognises the pairing and says so.
|
|
13
|
+
*
|
|
14
|
+
* Deliberately narrow, and it fails open. A Linux editor inside WSL (WSLg, `/usr/bin/code`)
|
|
15
|
+
* reads WSL's config and is never refused; neither is plain `ssh` from the WSL shell. A
|
|
16
|
+
* custom automount root (`/c/…` instead of `/mnt/c/…`) is not recognised, which leaves
|
|
17
|
+
* that candidate exactly where they were before this check.
|
|
18
|
+
*/
|
|
19
|
+
/** Inside WSL: the distro sets WSL_DISTRO_NAME, and both WSL kernels name Microsoft. */
|
|
20
|
+
export function isWsl(env = process.env, release = os.release(), platform = process.platform) {
|
|
21
|
+
if (platform !== "linux")
|
|
22
|
+
return false;
|
|
23
|
+
return Boolean(env.WSL_DISTRO_NAME) || /microsoft/i.test(release);
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* What exec would accept: a regular file (after following links) that we may execute.
|
|
27
|
+
* Greptile on #2830 — existence alone is not what the shell asks. A non-executable `code`
|
|
28
|
+
* earlier on PATH is skipped by the exec that ran the editor probe, so this lookup must
|
|
29
|
+
* skip it too, or it names a file that was never the editor.
|
|
30
|
+
*/
|
|
31
|
+
export function isExecutableFile(p) {
|
|
32
|
+
try {
|
|
33
|
+
if (!statSync(p).isFile())
|
|
34
|
+
return false;
|
|
35
|
+
accessSync(p, constants.X_OK);
|
|
36
|
+
return true;
|
|
37
|
+
}
|
|
38
|
+
catch {
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* The absolute path exec would run for `cmd`: the first executable file on `pathEnv`, or
|
|
44
|
+
* null. POSIX only — this is asked inside WSL, where PATH is colon-separated even when it
|
|
45
|
+
* lists Windows directories.
|
|
46
|
+
*/
|
|
47
|
+
export function whichOnPath(cmd, pathEnv, isExecutable = isExecutableFile) {
|
|
48
|
+
if (cmd.includes("/"))
|
|
49
|
+
return cmd;
|
|
50
|
+
for (const dir of (pathEnv ?? "").split(":")) {
|
|
51
|
+
if (!dir)
|
|
52
|
+
continue;
|
|
53
|
+
const candidate = path.posix.join(dir, cmd);
|
|
54
|
+
if (isExecutable(candidate))
|
|
55
|
+
return candidate;
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
/** A program that runs on the Windows side: on a mounted Windows drive, or a Windows executable. */
|
|
60
|
+
export function isWindowsSideProgram(absPath) {
|
|
61
|
+
return /^\/mnt\/[a-z]\//i.test(absPath) || /\.(exe|cmd|bat)$/i.test(absPath);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Whether `program` is a Windows-side editor, judged on what it RESOLVES to.
|
|
65
|
+
*
|
|
66
|
+
* Greptile on #2830, both directions: `/usr/local/bin/code` linked to the Windows install
|
|
67
|
+
* under `/mnt/c` is the Windows editor, and a link that sits under `/mnt/c` but points at
|
|
68
|
+
* a Linux editor is not. What runs is the target, so the target decides. Only a path that
|
|
69
|
+
* cannot be resolved is judged as written.
|
|
70
|
+
*/
|
|
71
|
+
export function windowsSideEditor(program, realpath = realpathSync) {
|
|
72
|
+
let target;
|
|
73
|
+
try {
|
|
74
|
+
target = realpath(program);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return isWindowsSideProgram(program);
|
|
78
|
+
}
|
|
79
|
+
return isWindowsSideProgram(target);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* The way out, for the refusal `connect` prints. It carries no token and no signed URL:
|
|
83
|
+
* `fatal` reports its hint to our event stream, and both are credentials. The browser
|
|
84
|
+
* route is named as a command instead, which re-opens the same workspace — with a
|
|
85
|
+
* `<token>` placeholder, because `connect` will not run without one.
|
|
86
|
+
*/
|
|
87
|
+
export function wslEditorHint(editorLabel, alias, browserIdeAvailable) {
|
|
88
|
+
const lines = [
|
|
89
|
+
`This terminal is WSL, so the SSH setup went into WSL's ~/.ssh, which ${editorLabel} on Windows`,
|
|
90
|
+
"cannot see. Run the same `litmus connect` command from PowerShell or Windows Terminal instead",
|
|
91
|
+
"(install the CLI there first: npm install -g litmus-cli@latest).",
|
|
92
|
+
`Or connect from this WSL terminal right now: ssh ${alias}`,
|
|
93
|
+
];
|
|
94
|
+
if (browserIdeAvailable) {
|
|
95
|
+
lines.push("Or open the workspace in your browser, nothing to install: `litmus connect <token> --ide browser`");
|
|
96
|
+
}
|
|
97
|
+
return lines.join("\n");
|
|
98
|
+
}
|
|
99
|
+
//# sourceMappingURL=wsl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wsl.js","sourceRoot":"","sources":["../../src/lib/wsl.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAA;AACnB,OAAO,IAAI,MAAM,MAAM,CAAA;AACvB,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,IAAI,CAAA;AAElE;;;;;;;;;;;;;;GAcG;AAEH,wFAAwF;AACxF,MAAM,UAAU,KAAK,CACnB,MAAy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