@celljs/ta-exec 4.6.1 → 4.7.0
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.en.md +43 -0
- package/README.md +5 -1
- package/esm/node/exec-client.d.ts +28 -11
- package/esm/node/exec-client.js +89 -33
- package/esm/node/exec-client.js.map +1 -1
- package/esm/node/exec-peer.d.ts +40 -0
- package/esm/node/exec-peer.js +167 -0
- package/esm/node/exec-peer.js.map +1 -0
- package/esm/node/exec-protocol.d.ts +14 -0
- package/esm/node/exec-remote-source.d.ts +5 -0
- package/esm/node/exec-remote-source.js +9 -0
- package/esm/node/exec-remote-source.js.map +1 -0
- package/esm/node/exec-rpc.d.ts +21 -3
- package/esm/node/exec-rpc.js +14 -3
- package/esm/node/exec-rpc.js.map +1 -1
- package/esm/node/exec-server.d.ts +2 -26
- package/esm/node/exec-server.js +3 -132
- package/esm/node/exec-server.js.map +1 -1
- package/esm/node/exec-stdio.d.ts +27 -0
- package/esm/node/exec-stdio.js +60 -0
- package/esm/node/exec-stdio.js.map +1 -0
- package/esm/node/index.d.ts +8 -0
- package/esm/node/index.js +8 -0
- package/esm/node/index.js.map +1 -1
- package/esm/node/local-exec-environment.js +8 -8
- package/esm/node/local-exec-environment.js.map +1 -1
- package/esm/node/remote-exec-environment.d.ts +2 -1
- package/esm/node/remote-exec-environment.js +39 -0
- package/esm/node/remote-exec-environment.js.map +1 -1
- package/esm/node/ssh/node-dist.d.ts +20 -0
- package/esm/node/ssh/node-dist.js +77 -0
- package/esm/node/ssh/node-dist.js.map +1 -0
- package/esm/node/ssh/ssh-askpass.d.ts +24 -0
- package/esm/node/ssh/ssh-askpass.js +112 -0
- package/esm/node/ssh/ssh-askpass.js.map +1 -0
- package/esm/node/ssh/ssh-config.d.ts +20 -0
- package/esm/node/ssh/ssh-config.js +127 -0
- package/esm/node/ssh/ssh-config.js.map +1 -0
- package/esm/node/ssh/ssh-host.d.ts +73 -0
- package/esm/node/ssh/ssh-host.js +258 -0
- package/esm/node/ssh/ssh-host.js.map +1 -0
- package/esm/node/ssh/ssh-util.d.ts +45 -0
- package/esm/node/ssh/ssh-util.js +110 -0
- package/esm/node/ssh/ssh-util.js.map +1 -0
- package/lib/node/exec-client.d.ts +28 -11
- package/lib/node/exec-client.d.ts.map +1 -1
- package/lib/node/exec-client.js +89 -33
- package/lib/node/exec-client.js.map +1 -1
- package/lib/node/exec-peer.d.ts +41 -0
- package/lib/node/exec-peer.d.ts.map +1 -0
- package/lib/node/exec-peer.js +171 -0
- package/lib/node/exec-peer.js.map +1 -0
- package/lib/node/exec-protocol.d.ts +14 -0
- package/lib/node/exec-protocol.d.ts.map +1 -1
- package/lib/node/exec-remote-source.d.ts +6 -0
- package/lib/node/exec-remote-source.d.ts.map +1 -0
- package/lib/node/exec-remote-source.js +10 -0
- package/lib/node/exec-remote-source.js.map +1 -0
- package/lib/node/exec-rpc.d.ts +21 -3
- package/lib/node/exec-rpc.d.ts.map +1 -1
- package/lib/node/exec-rpc.js +14 -3
- package/lib/node/exec-rpc.js.map +1 -1
- package/lib/node/exec-server.d.ts +2 -26
- package/lib/node/exec-server.d.ts.map +1 -1
- package/lib/node/exec-server.js +4 -134
- package/lib/node/exec-server.js.map +1 -1
- package/lib/node/exec-server.spec.js +1 -1
- package/lib/node/exec-server.spec.js.map +1 -1
- package/lib/node/exec-stdio.d.ts +28 -0
- package/lib/node/exec-stdio.d.ts.map +1 -0
- package/lib/node/exec-stdio.js +64 -0
- package/lib/node/exec-stdio.js.map +1 -0
- package/lib/node/exec-stdio.spec.d.ts +2 -0
- package/lib/node/exec-stdio.spec.d.ts.map +1 -0
- package/lib/node/exec-stdio.spec.js +105 -0
- package/lib/node/exec-stdio.spec.js.map +1 -0
- package/lib/node/index.d.ts +8 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +8 -0
- package/lib/node/index.js.map +1 -1
- package/lib/node/local-exec-environment.d.ts.map +1 -1
- package/lib/node/local-exec-environment.js +8 -8
- package/lib/node/local-exec-environment.js.map +1 -1
- package/lib/node/remote-exec-environment.d.ts +2 -1
- package/lib/node/remote-exec-environment.d.ts.map +1 -1
- package/lib/node/remote-exec-environment.js +39 -0
- package/lib/node/remote-exec-environment.js.map +1 -1
- package/lib/node/ssh/node-dist.d.ts +21 -0
- package/lib/node/ssh/node-dist.d.ts.map +1 -0
- package/lib/node/ssh/node-dist.js +80 -0
- package/lib/node/ssh/node-dist.js.map +1 -0
- package/lib/node/ssh/ssh-askpass.d.ts +25 -0
- package/lib/node/ssh/ssh-askpass.d.ts.map +1 -0
- package/lib/node/ssh/ssh-askpass.js +114 -0
- package/lib/node/ssh/ssh-askpass.js.map +1 -0
- package/lib/node/ssh/ssh-config.d.ts +21 -0
- package/lib/node/ssh/ssh-config.d.ts.map +1 -0
- package/lib/node/ssh/ssh-config.js +130 -0
- package/lib/node/ssh/ssh-config.js.map +1 -0
- package/lib/node/ssh/ssh-host.d.ts +74 -0
- package/lib/node/ssh/ssh-host.d.ts.map +1 -0
- package/lib/node/ssh/ssh-host.js +262 -0
- package/lib/node/ssh/ssh-host.js.map +1 -0
- package/lib/node/ssh/ssh-host.spec.d.ts +2 -0
- package/lib/node/ssh/ssh-host.spec.d.ts.map +1 -0
- package/lib/node/ssh/ssh-host.spec.js +182 -0
- package/lib/node/ssh/ssh-host.spec.js.map +1 -0
- package/lib/node/ssh/ssh-util.d.ts +46 -0
- package/lib/node/ssh/ssh-util.d.ts.map +1 -0
- package/lib/node/ssh/ssh-util.js +113 -0
- package/lib/node/ssh/ssh-util.js.map +1 -0
- package/lib/node/ssh/ssh-util.spec.d.ts +2 -0
- package/lib/node/ssh/ssh-util.spec.d.ts.map +1 -0
- package/lib/node/ssh/ssh-util.spec.js +87 -0
- package/lib/node/ssh/ssh-util.spec.js.map +1 -0
- package/package.json +3 -3
- package/src/node/exec-client.ts +108 -39
- package/src/node/exec-peer.ts +186 -0
- package/src/node/exec-protocol.ts +15 -0
- package/src/node/exec-remote-source.ts +7 -0
- package/src/node/exec-rpc.ts +23 -3
- package/src/node/exec-server.spec.ts +1 -1
- package/src/node/exec-server.ts +4 -140
- package/src/node/exec-stdio.spec.ts +107 -0
- package/src/node/exec-stdio.ts +75 -0
- package/src/node/index.ts +8 -0
- package/src/node/local-exec-environment.ts +7 -6
- package/src/node/remote-exec-environment.ts +39 -1
- package/src/node/ssh/node-dist.ts +83 -0
- package/src/node/ssh/ssh-askpass.ts +117 -0
- package/src/node/ssh/ssh-config.ts +128 -0
- package/src/node/ssh/ssh-host.spec.ts +189 -0
- package/src/node/ssh/ssh-host.ts +300 -0
- package/src/node/ssh/ssh-util.spec.ts +97 -0
- package/src/node/ssh/ssh-util.ts +127 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { type ChildProcess } from 'node:child_process';
|
|
2
|
+
import type { Readable } from 'node:stream';
|
|
3
|
+
import { ExecClient, type ExecConnection, ExecError } from '../exec-client';
|
|
4
|
+
import { SshAskpass } from './ssh-askpass';
|
|
5
|
+
import { type SshProbe, type SshQuestion } from './ssh-util';
|
|
6
|
+
/** The steps of connecting, as TaRemoteStep names them. */
|
|
7
|
+
export type SshStep = 'connecting' | 'checking' | 'installing-node' | 'copying-server' | 'starting';
|
|
8
|
+
export interface SshHostOptions {
|
|
9
|
+
/** What ssh takes: a Host of its configuration, or `[user@]host[:port]`. */
|
|
10
|
+
host: string;
|
|
11
|
+
/** Where this machine keeps the sockets of ssh, the askpass script and downloaded Node.js. */
|
|
12
|
+
stateDir: string;
|
|
13
|
+
/** Default `ssh`, the OpenSSH client of the system with its configuration. */
|
|
14
|
+
ssh?: string;
|
|
15
|
+
/** Before the host, as `-F <file>`. */
|
|
16
|
+
sshArgs?: string[];
|
|
17
|
+
/** What ssh asks (a password, a new host key); undefined cancels. Without it, ssh asks nobody. */
|
|
18
|
+
ask?(question: SshQuestion): Promise<string | undefined>;
|
|
19
|
+
onStep?(step: SshStep, detail?: string): void;
|
|
20
|
+
/** Where Node.js comes from for a host without one; default nodejs.org. */
|
|
21
|
+
nodeMirror?: string;
|
|
22
|
+
/** For tests: the server to copy. */
|
|
23
|
+
server?: {
|
|
24
|
+
hash: string;
|
|
25
|
+
script: string;
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
interface RunResult {
|
|
29
|
+
code: number | null;
|
|
30
|
+
stdout: string;
|
|
31
|
+
stderr: string;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Another machine through the `ssh` of this one, as VS Code's Remote SSH reaches it: one ssh of its own
|
|
35
|
+
* signs in (and asks through {@link SshHostOptions.ask}), the others share its connection
|
|
36
|
+
* (ControlMaster, never the user's own). The first time, it copies a small `ta exec-server` there,
|
|
37
|
+
* with Node.js when the host has none, and then runs it on the standard input and output of ssh.
|
|
38
|
+
* Only processes it started are ended; what the server started there ends with its input.
|
|
39
|
+
*/
|
|
40
|
+
export declare class SshHost {
|
|
41
|
+
protected readonly options: SshHostOptions;
|
|
42
|
+
readonly client: ExecClient;
|
|
43
|
+
protected master?: ChildProcess;
|
|
44
|
+
protected ready?: Promise<void>;
|
|
45
|
+
protected askpass?: SshAskpass;
|
|
46
|
+
protected readonly running: Set<ChildProcess>;
|
|
47
|
+
protected disposed: boolean;
|
|
48
|
+
constructor(options: SshHostOptions);
|
|
49
|
+
get host(): string;
|
|
50
|
+
/** Ends the server there, the connection, and every ssh this object started. */
|
|
51
|
+
dispose(): Promise<void>;
|
|
52
|
+
protected launch(): Promise<ExecConnection>;
|
|
53
|
+
protected probe(hash: string): Promise<SshProbe>;
|
|
54
|
+
protected installNode(probe: SshProbe): Promise<string>;
|
|
55
|
+
/** The server on the standard input and output of an ssh: one message per line. */
|
|
56
|
+
protected start(node: string, script: string): Promise<ExecConnection>;
|
|
57
|
+
/** The ssh that signs in, and stays for the others to share; none on Windows, whose ssh cannot share. */
|
|
58
|
+
protected connectMaster(): Promise<void>;
|
|
59
|
+
protected openMaster(): Promise<void>;
|
|
60
|
+
protected control(command: string): Promise<number | null>;
|
|
61
|
+
/** Runs a script there, with `input` on its standard input. */
|
|
62
|
+
protected run(script: string, args?: string[], input?: string | Readable): Promise<RunResult>;
|
|
63
|
+
protected check(running: Promise<RunResult>, what: string): Promise<RunResult>;
|
|
64
|
+
protected spawn(remote: string[], env: NodeJS.ProcessEnv): ChildProcess;
|
|
65
|
+
protected common(): string[];
|
|
66
|
+
protected destination(): string;
|
|
67
|
+
/** In the state directory, or a short one of this user when that path is too long for a socket. */
|
|
68
|
+
protected controlPath(): string;
|
|
69
|
+
protected env(): Promise<NodeJS.ProcessEnv>;
|
|
70
|
+
protected step(step: SshStep, detail?: string): void;
|
|
71
|
+
protected error(message: string): ExecError;
|
|
72
|
+
}
|
|
73
|
+
export {};
|
|
74
|
+
//# sourceMappingURL=ssh-host.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh-host.d.ts","sourceRoot":"","sources":["../../../src/node/ssh/ssh-host.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAS,MAAM,oBAAoB,CAAC;AAG9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,KAAK,cAAc,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAI5E,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,WAAW,EAAW,MAAM,YAAY,CAAC;AAEtE,2DAA2D;AAC3D,MAAM,MAAM,OAAO,GAAG,YAAY,GAAG,UAAU,GAAG,iBAAiB,GAAG,gBAAgB,GAAG,UAAU,CAAC;AAEpG,MAAM,WAAW,cAAc;IAC3B,4EAA4E;IAC5E,IAAI,EAAE,MAAM,CAAC;IACb,8FAA8F;IAC9F,QAAQ,EAAE,MAAM,CAAC;IACjB,8EAA8E;IAC9E,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,uCAAuC;IACvC,OAA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: true });
|
|
3
|
+
exports.SshHost = void 0;
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
|
+
const node_fs_1 = require("node:fs");
|
|
6
|
+
const node_path_1 = require("node:path");
|
|
7
|
+
const exec_client_1 = require("../exec-client");
|
|
8
|
+
const exec_remote_source_1 = require("../exec-remote-source");
|
|
9
|
+
const exec_rpc_1 = require("../exec-rpc");
|
|
10
|
+
const node_dist_1 = require("./node-dist");
|
|
11
|
+
const ssh_askpass_1 = require("./ssh-askpass");
|
|
12
|
+
const ssh_util_1 = require("./ssh-util");
|
|
13
|
+
/** The pings of the client; the server ends after four times this without any message. */
|
|
14
|
+
const PING_MS = 15000;
|
|
15
|
+
const CHECK_MS = 150;
|
|
16
|
+
/** A Unix socket's path has at most 104 bytes: `/%C` takes 41, and ssh adds 17 while it creates one. */
|
|
17
|
+
const MAX_SOCKET_DIR = 44;
|
|
18
|
+
const STDERR_KEPT = 2000;
|
|
19
|
+
const STOP_MS = 2000;
|
|
20
|
+
/**
|
|
21
|
+
* Another machine through the `ssh` of this one, as VS Code's Remote SSH reaches it: one ssh of its own
|
|
22
|
+
* signs in (and asks through {@link SshHostOptions.ask}), the others share its connection
|
|
23
|
+
* (ControlMaster, never the user's own). The first time, it copies a small `ta exec-server` there,
|
|
24
|
+
* with Node.js when the host has none, and then runs it on the standard input and output of ssh.
|
|
25
|
+
* Only processes it started are ended; what the server started there ends with its input.
|
|
26
|
+
*/
|
|
27
|
+
class SshHost {
|
|
28
|
+
constructor(options) {
|
|
29
|
+
this.options = options;
|
|
30
|
+
this.running = new Set();
|
|
31
|
+
this.disposed = false;
|
|
32
|
+
this.client = new exec_client_1.ExecClient({ epoch: Date.now(), pingMs: PING_MS, connect: () => this.launch() });
|
|
33
|
+
}
|
|
34
|
+
get host() {
|
|
35
|
+
return this.options.host;
|
|
36
|
+
}
|
|
37
|
+
/** Ends the server there, the connection, and every ssh this object started. */
|
|
38
|
+
async dispose() {
|
|
39
|
+
var _a;
|
|
40
|
+
this.disposed = true;
|
|
41
|
+
this.client.close();
|
|
42
|
+
for (const child of this.running) {
|
|
43
|
+
child.kill();
|
|
44
|
+
}
|
|
45
|
+
const master = this.master;
|
|
46
|
+
this.master = undefined;
|
|
47
|
+
this.ready = undefined;
|
|
48
|
+
if (master && master.exitCode === null && master.signalCode === null) {
|
|
49
|
+
const exited = new Promise(resolve => master.once('close', resolve));
|
|
50
|
+
master.kill();
|
|
51
|
+
const timer = setTimeout(() => master.kill('SIGKILL'), STOP_MS);
|
|
52
|
+
await exited;
|
|
53
|
+
clearTimeout(timer);
|
|
54
|
+
}
|
|
55
|
+
await ((_a = this.askpass) === null || _a === void 0 ? void 0 : _a.close());
|
|
56
|
+
}
|
|
57
|
+
async launch() {
|
|
58
|
+
var _a, _b;
|
|
59
|
+
if (this.disposed) {
|
|
60
|
+
throw new exec_client_1.ExecError(`The connection to ${this.host} was closed.`, exec_rpc_1.ExecRpc.ErrorCode.CONNECTION_LOST);
|
|
61
|
+
}
|
|
62
|
+
this.step('connecting');
|
|
63
|
+
await this.connectMaster();
|
|
64
|
+
this.step('checking');
|
|
65
|
+
const server = (_a = this.options.server) !== null && _a !== void 0 ? _a : exec_remote_source_1.EXEC_REMOTE_SOURCE;
|
|
66
|
+
const probe = await this.probe(server.hash);
|
|
67
|
+
const node = (_b = probe.node) !== null && _b !== void 0 ? _b : (await this.installNode(probe));
|
|
68
|
+
const script = `${probe.home}/${ssh_util_1.SshUtil.REMOTE_DIR}/${server.hash}/exec-server.js`;
|
|
69
|
+
if (!probe.server) {
|
|
70
|
+
this.step('copying-server');
|
|
71
|
+
await this.check(this.run(ssh_util_1.SshUtil.uploadScript(`${server.hash}/exec-server.js`), [], server.script), 'copy the server of Ta');
|
|
72
|
+
}
|
|
73
|
+
this.step('starting');
|
|
74
|
+
return this.start(node, script);
|
|
75
|
+
}
|
|
76
|
+
async probe(hash) {
|
|
77
|
+
const result = await this.check(this.run(ssh_util_1.SshUtil.probeScript(hash)), 'look at the host');
|
|
78
|
+
const probe = ssh_util_1.SshUtil.parseProbe(result.stdout);
|
|
79
|
+
if (!probe) {
|
|
80
|
+
throw this.error(`${this.host} has no POSIX shell: Ta works on Linux and macOS hosts.`);
|
|
81
|
+
}
|
|
82
|
+
return probe;
|
|
83
|
+
}
|
|
84
|
+
async installNode(probe) {
|
|
85
|
+
const platform = ssh_util_1.SshUtil.nodePlatform(probe.os, probe.arch);
|
|
86
|
+
if (!platform || probe.musl) {
|
|
87
|
+
throw this.error(`${this.host} (${probe.os} ${probe.arch}${probe.musl ? ', musl' : ''}) has no Node.js ${ssh_util_1.SshUtil.MIN_NODE_MAJOR} or later, and Node.js has no build Ta can install there: install one there.`);
|
|
88
|
+
}
|
|
89
|
+
this.step('installing-node');
|
|
90
|
+
const tarball = await node_dist_1.NodeDist.download(platform, (0, node_path_1.join)(this.options.stateDir, 'node'), this.options.nodeMirror, version => this.step('installing-node', version));
|
|
91
|
+
await this.check(this.run(ssh_util_1.SshUtil.installNodeScript(), [], (0, node_fs_1.createReadStream)(tarball.file)), 'install Node.js');
|
|
92
|
+
return `${probe.home}/${ssh_util_1.SshUtil.REMOTE_DIR}/node/bin/node`;
|
|
93
|
+
}
|
|
94
|
+
/** The server on the standard input and output of an ssh: one message per line. */
|
|
95
|
+
async start(node, script) {
|
|
96
|
+
var _a, _b, _c;
|
|
97
|
+
const child = this.spawn([ssh_util_1.SshUtil.remoteCommand(ssh_util_1.SshUtil.launchScript(), node, script)], await this.env());
|
|
98
|
+
const messages = new Set();
|
|
99
|
+
let closed;
|
|
100
|
+
let closing = false;
|
|
101
|
+
let rest = '';
|
|
102
|
+
let stderr = '';
|
|
103
|
+
(_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on('data', data => {
|
|
104
|
+
var _a;
|
|
105
|
+
const lines = (rest + data.toString()).split('\n');
|
|
106
|
+
rest = (_a = lines.pop()) !== null && _a !== void 0 ? _a : '';
|
|
107
|
+
for (const line of lines) {
|
|
108
|
+
for (const listener of messages) {
|
|
109
|
+
listener(line);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
(_b = child.stderr) === null || _b === void 0 ? void 0 : _b.on('data', data => (stderr = (stderr + data.toString()).slice(-STDERR_KEPT)));
|
|
114
|
+
(_c = child.stdin) === null || _c === void 0 ? void 0 : _c.on('error', () => undefined);
|
|
115
|
+
child.once('close', code => {
|
|
116
|
+
const reason = stderr.trim() || `ssh to ${this.host} ended with code ${code}.`;
|
|
117
|
+
closed === null || closed === void 0 ? void 0 : closed(closing ? undefined : `The connection to ${this.host} was lost: ${reason}`);
|
|
118
|
+
});
|
|
119
|
+
return {
|
|
120
|
+
send: text => { var _a; return (_a = child.stdin) === null || _a === void 0 ? void 0 : _a.write(`${text}\n`); },
|
|
121
|
+
close: () => {
|
|
122
|
+
closing = true;
|
|
123
|
+
child.kill();
|
|
124
|
+
},
|
|
125
|
+
onMessage: listener => messages.add(listener),
|
|
126
|
+
onClose: listener => (closed = listener),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
/** The ssh that signs in, and stays for the others to share; none on Windows, whose ssh cannot share. */
|
|
130
|
+
connectMaster() {
|
|
131
|
+
var _a;
|
|
132
|
+
if (process.platform === 'win32') {
|
|
133
|
+
return Promise.resolve();
|
|
134
|
+
}
|
|
135
|
+
(_a = this.ready) !== null && _a !== void 0 ? _a : (this.ready = this.openMaster().catch(error => {
|
|
136
|
+
this.ready = undefined;
|
|
137
|
+
throw error;
|
|
138
|
+
}));
|
|
139
|
+
return this.ready;
|
|
140
|
+
}
|
|
141
|
+
async openMaster() {
|
|
142
|
+
var _a;
|
|
143
|
+
var _b;
|
|
144
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.dirname)(this.controlPath()), { recursive: true, mode: 0o700 });
|
|
145
|
+
const env = await this.env();
|
|
146
|
+
const master = (0, node_child_process_1.spawn)((_b = this.options.ssh) !== null && _b !== void 0 ? _b : 'ssh', [...this.common(), '-N', '-o', 'ControlMaster=yes', '-o', 'ControlPersist=no', '-o', `ControlPath=${this.controlPath()}`, '--', this.destination()], { stdio: ['ignore', 'ignore', 'pipe'], env });
|
|
147
|
+
this.master = master;
|
|
148
|
+
let stderr = '';
|
|
149
|
+
(_a = master.stderr) === null || _a === void 0 ? void 0 : _a.on('data', data => (stderr = (stderr + data.toString()).slice(-STDERR_KEPT)));
|
|
150
|
+
const exited = new Promise(resolve => master.once('close', resolve));
|
|
151
|
+
void exited.then(() => {
|
|
152
|
+
if (this.master === master) {
|
|
153
|
+
this.master = undefined;
|
|
154
|
+
this.ready = undefined;
|
|
155
|
+
}
|
|
156
|
+
});
|
|
157
|
+
for (;;) {
|
|
158
|
+
const done = await Promise.race([exited, new Promise(resolve => setTimeout(() => resolve('wait'), CHECK_MS))]);
|
|
159
|
+
if (done !== 'wait') {
|
|
160
|
+
throw this.error(stderr.trim() || `ssh cannot connect to ${this.host}.`);
|
|
161
|
+
}
|
|
162
|
+
if ((await this.control('check')) === 0) {
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
control(command) {
|
|
168
|
+
var _a;
|
|
169
|
+
const child = (0, node_child_process_1.spawn)((_a = this.options.ssh) !== null && _a !== void 0 ? _a : 'ssh', [...this.common(), '-O', command, '-o', `ControlPath=${this.controlPath()}`, '--', this.destination()], {
|
|
170
|
+
stdio: 'ignore',
|
|
171
|
+
});
|
|
172
|
+
return new Promise(resolve => {
|
|
173
|
+
child.once('error', () => resolve(null));
|
|
174
|
+
child.once('close', resolve);
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/** Runs a script there, with `input` on its standard input. */
|
|
178
|
+
async run(script, args = [], input) {
|
|
179
|
+
var _a, _b, _c, _d, _e;
|
|
180
|
+
const child = this.spawn([ssh_util_1.SshUtil.remoteCommand(script, ...args)], await this.env());
|
|
181
|
+
this.running.add(child);
|
|
182
|
+
let stdout = '';
|
|
183
|
+
let stderr = '';
|
|
184
|
+
(_a = child.stdout) === null || _a === void 0 ? void 0 : _a.on('data', data => (stdout += data.toString()));
|
|
185
|
+
(_b = child.stderr) === null || _b === void 0 ? void 0 : _b.on('data', data => (stderr = (stderr + data.toString()).slice(-STDERR_KEPT)));
|
|
186
|
+
(_c = child.stdin) === null || _c === void 0 ? void 0 : _c.on('error', () => undefined);
|
|
187
|
+
if (typeof input === 'string') {
|
|
188
|
+
(_d = child.stdin) === null || _d === void 0 ? void 0 : _d.end(input);
|
|
189
|
+
}
|
|
190
|
+
else if (input) {
|
|
191
|
+
input.pipe(child.stdin);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
(_e = child.stdin) === null || _e === void 0 ? void 0 : _e.end();
|
|
195
|
+
}
|
|
196
|
+
return new Promise(resolve => {
|
|
197
|
+
child.once('error', error => resolve({ code: null, stdout, stderr: error.message }));
|
|
198
|
+
child.once('close', code => {
|
|
199
|
+
this.running.delete(child);
|
|
200
|
+
resolve({ code, stdout, stderr });
|
|
201
|
+
});
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
async check(running, what) {
|
|
205
|
+
const result = await running;
|
|
206
|
+
if (result.code !== 0) {
|
|
207
|
+
throw this.error(`Ta could not ${what} on ${this.host}: ${result.stderr.trim() || `ssh ended with code ${result.code}`}`);
|
|
208
|
+
}
|
|
209
|
+
return result;
|
|
210
|
+
}
|
|
211
|
+
spawn(remote, env) {
|
|
212
|
+
var _a;
|
|
213
|
+
const shared = process.platform === 'win32' ? [] : ['-o', 'ControlMaster=no', '-o', `ControlPath=${this.controlPath()}`];
|
|
214
|
+
return (0, node_child_process_1.spawn)((_a = this.options.ssh) !== null && _a !== void 0 ? _a : 'ssh', [...this.common(), ...shared, '-T', '--', this.destination(), ...remote], {
|
|
215
|
+
stdio: ['pipe', 'pipe', 'pipe'],
|
|
216
|
+
env,
|
|
217
|
+
});
|
|
218
|
+
}
|
|
219
|
+
common() {
|
|
220
|
+
var _a;
|
|
221
|
+
return [
|
|
222
|
+
...((_a = this.options.sshArgs) !== null && _a !== void 0 ? _a : []),
|
|
223
|
+
'-o',
|
|
224
|
+
'ServerAliveInterval=15',
|
|
225
|
+
'-o',
|
|
226
|
+
'ServerAliveCountMax=3',
|
|
227
|
+
'-o',
|
|
228
|
+
'ConnectTimeout=20',
|
|
229
|
+
'-o',
|
|
230
|
+
'LogLevel=ERROR',
|
|
231
|
+
];
|
|
232
|
+
}
|
|
233
|
+
destination() {
|
|
234
|
+
return ssh_util_1.SshUtil.destination(this.host);
|
|
235
|
+
}
|
|
236
|
+
/** In the state directory, or a short one of this user when that path is too long for a socket. */
|
|
237
|
+
controlPath() {
|
|
238
|
+
var _a;
|
|
239
|
+
var _b;
|
|
240
|
+
const dir = (0, node_path_1.join)(this.options.stateDir, 'ssh');
|
|
241
|
+
const short = dir.length <= MAX_SOCKET_DIR ? dir : `/tmp/ta-ssh-${(_b = (_a = process.getuid) === null || _a === void 0 ? void 0 : _a.call(process)) !== null && _b !== void 0 ? _b : 'user'}`;
|
|
242
|
+
return (0, node_path_1.join)(short, '%C');
|
|
243
|
+
}
|
|
244
|
+
async env() {
|
|
245
|
+
var _a;
|
|
246
|
+
const ask = this.options.ask;
|
|
247
|
+
if (!ask) {
|
|
248
|
+
return process.env;
|
|
249
|
+
}
|
|
250
|
+
(_a = this.askpass) !== null && _a !== void 0 ? _a : (this.askpass = new ssh_askpass_1.SshAskpass((0, node_path_1.dirname)(this.controlPath()), ask));
|
|
251
|
+
return this.askpass.env();
|
|
252
|
+
}
|
|
253
|
+
step(step, detail) {
|
|
254
|
+
var _a, _b;
|
|
255
|
+
(_b = (_a = this.options).onStep) === null || _b === void 0 ? void 0 : _b.call(_a, step, detail);
|
|
256
|
+
}
|
|
257
|
+
error(message) {
|
|
258
|
+
return new exec_client_1.ExecError(message, exec_rpc_1.ExecRpc.ErrorCode.CONNECTION_LOST);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
exports.SshHost = SshHost;
|
|
262
|
+
//# sourceMappingURL=ssh-host.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IAAI,CAAC,CAAC;IAC7B,CAAC;IAES,KAAK,CAAC,GAAG;;QACf,MAAM,GAAG,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC;QAC7B,IAAI,CAAC,GAAG,EAAE,CAAC;YACP,OAAO,OAAO,CAAC,GAAG,CAAC;QACvB,CAAC;QACD,MAAA,IAAI,CAAC,OAAO,oCAAZ,IAAI,CAAC,OAAO,GAAK,IAAI,wBAAU,CAAC,IAAA,mBAAO,EAAC,IAAI,CAAC,WAAW,EAAE,CAAC,EAAE,GAAG,CAAC,EAAC;QAClE,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC;IAC9B,CAAC;IAES,IAAI,CAAC,IAAa,EAAE,MAAe;;QACzC,MAAA,MAAA,IAAI,CAAC,OAAO,EAAC,MAAM,mDAAG,IAAI,EAAE,MAAM,CAAC,CAAC;IACxC,CAAC;IAES,KAAK,CAAC,OAAe;QAC3B,OAAO,IAAI,uBAAS,CAAC,OAAO,EAAE,kBAAO,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC;IACrE,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh-host.spec.d.ts","sourceRoot":"","sources":["../../../src/node/ssh/ssh-host.spec.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const bun_test_1 = require("bun:test");
|
|
4
|
+
const node_child_process_1 = require("node:child_process");
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
const node_fs_1 = require("node:fs");
|
|
7
|
+
const node_http_1 = require("node:http");
|
|
8
|
+
const node_os_1 = require("node:os");
|
|
9
|
+
const node_path_1 = require("node:path");
|
|
10
|
+
const remote_exec_environment_1 = require("../remote-exec-environment");
|
|
11
|
+
const ssh_host_1 = require("./ssh-host");
|
|
12
|
+
const ssh_util_1 = require("./ssh-util");
|
|
13
|
+
/**
|
|
14
|
+
* An ssh that runs the command on this machine, as ssh would on the host: in the home directory of the
|
|
15
|
+
* test, with a PATH of the test. Its master is a process that waits; it asks for a password through
|
|
16
|
+
* SSH_ASKPASS when FAKE_SSH_PASSWORD is set.
|
|
17
|
+
*/
|
|
18
|
+
const FAKE_SSH = `#!/bin/sh
|
|
19
|
+
echo "$*" >> "$FAKE_SSH_DIR/log"
|
|
20
|
+
master=0; control=
|
|
21
|
+
while [ $# -gt 0 ]; do
|
|
22
|
+
case "$1" in
|
|
23
|
+
--) shift; break;;
|
|
24
|
+
-N) master=1; shift;;
|
|
25
|
+
-T) shift;;
|
|
26
|
+
-O) control="$2"; shift 2;;
|
|
27
|
+
-o|-F|-p|-i|-l) shift 2;;
|
|
28
|
+
*) shift;;
|
|
29
|
+
esac
|
|
30
|
+
done
|
|
31
|
+
shift
|
|
32
|
+
if [ -n "$control" ]; then [ -f "$FAKE_SSH_DIR/master" ]; exit $?; fi
|
|
33
|
+
if [ "$master" = 1 ]; then
|
|
34
|
+
if [ -n "$FAKE_SSH_PASSWORD" ]; then
|
|
35
|
+
answer=$("$SSH_ASKPASS" "fake's password: ") || { echo "Permission denied (cancelled)." >&2; exit 255; }
|
|
36
|
+
[ "$answer" = "$FAKE_SSH_PASSWORD" ] || { echo "Permission denied (password)." >&2; exit 255; }
|
|
37
|
+
fi
|
|
38
|
+
touch "$FAKE_SSH_DIR/master"
|
|
39
|
+
trap 'rm -f "$FAKE_SSH_DIR/master"; exit 0' TERM INT
|
|
40
|
+
while :; do sleep 1 & wait $!; done
|
|
41
|
+
fi
|
|
42
|
+
[ -f "$FAKE_SSH_DIR/master" ] || { echo "no master" >&2; exit 255; }
|
|
43
|
+
cmd=$(printf '%s' "$*" | sed -e 's#/opt/homebrew/bin/node#/none#g' -e 's#/usr/local/bin/node#/none#g')
|
|
44
|
+
HOME="$FAKE_SSH_HOME" PATH="$FAKE_SSH_PATH" SHELL="$FAKE_SSH_DIR/login-sh" exec /bin/sh -c "$cmd"
|
|
45
|
+
`;
|
|
46
|
+
/**
|
|
47
|
+
* The login shell of the host, with the PATH of the test: a real one reads /etc/profile, whose PATH on
|
|
48
|
+
* macOS has /usr/local/bin, where the runners of CI have a Node.js.
|
|
49
|
+
*/
|
|
50
|
+
const LOGIN_SH = `#!/bin/sh
|
|
51
|
+
[ "$1" = -lc ] && shift && set -- -c "$@"
|
|
52
|
+
exec /bin/sh "$@"
|
|
53
|
+
`;
|
|
54
|
+
const which = (name) => (0, node_child_process_1.execFileSync)('/bin/sh', ['-c', `command -v ${name} || true`])
|
|
55
|
+
.toString()
|
|
56
|
+
.trim();
|
|
57
|
+
const node = which('node');
|
|
58
|
+
bun_test_1.describe.skipIf(process.platform === 'win32' || !node)('SshHost', () => {
|
|
59
|
+
const root = (0, node_fs_1.mkdtempSync)((0, node_path_1.join)((0, node_os_1.tmpdir)(), 'ta-ssh-host-'));
|
|
60
|
+
const ssh = (0, node_path_1.join)(root, 'ssh');
|
|
61
|
+
/** A PATH with the tools the scripts use, and no Node.js. */
|
|
62
|
+
const bare = (0, node_path_1.join)(root, 'bin');
|
|
63
|
+
const hosts = [];
|
|
64
|
+
let mirror;
|
|
65
|
+
let mirrorUrl;
|
|
66
|
+
const steps = [];
|
|
67
|
+
const host = (options = {}) => {
|
|
68
|
+
const created = new ssh_host_1.SshHost({ host: 'fake', stateDir: (0, node_path_1.join)(root, 'state'), ssh, onStep: step => steps.push(step), nodeMirror: mirrorUrl, ...options });
|
|
69
|
+
hosts.push(created);
|
|
70
|
+
return created;
|
|
71
|
+
};
|
|
72
|
+
const remote = (name, path) => {
|
|
73
|
+
const home = (0, node_path_1.join)(root, name);
|
|
74
|
+
(0, node_fs_1.mkdirSync)(home, { recursive: true });
|
|
75
|
+
process.env.FAKE_SSH_HOME = home;
|
|
76
|
+
process.env.FAKE_SSH_PATH = path;
|
|
77
|
+
return home;
|
|
78
|
+
};
|
|
79
|
+
(0, bun_test_1.beforeAll)(async () => {
|
|
80
|
+
(0, node_fs_1.writeFileSync)(ssh, FAKE_SSH, { mode: 0o755 });
|
|
81
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(root, 'login-sh'), LOGIN_SH, { mode: 0o755 });
|
|
82
|
+
process.env.FAKE_SSH_DIR = root;
|
|
83
|
+
(0, node_fs_1.mkdirSync)(bare);
|
|
84
|
+
for (const tool of ['sh', 'uname', 'tar', 'gzip', 'cat', 'mkdir', 'mv', 'rm', 'dirname', 'tail', 'ls', 'sleep', 'sed']) {
|
|
85
|
+
(0, node_fs_1.symlinkSync)(which(tool), (0, node_path_1.join)(bare, tool));
|
|
86
|
+
}
|
|
87
|
+
// A mirror of nodejs.org with one build, for this machine, whose node runs the real one.
|
|
88
|
+
const platform = ssh_util_1.SshUtil.nodePlatform((0, node_child_process_1.execFileSync)('uname', ['-s']).toString().trim(), (0, node_child_process_1.execFileSync)('uname', ['-m']).toString().trim());
|
|
89
|
+
const name = `node-v22.99.0-${platform}`;
|
|
90
|
+
(0, node_fs_1.mkdirSync)((0, node_path_1.join)(root, 'dist', name, 'bin'), { recursive: true });
|
|
91
|
+
(0, node_fs_1.writeFileSync)((0, node_path_1.join)(root, 'dist', name, 'bin', 'node'), `#!/bin/sh\nexec "${node}" "$@"\n`, { mode: 0o755 });
|
|
92
|
+
(0, node_child_process_1.execFileSync)('tar', ['-czf', `${name}.tar.gz`, name], { cwd: (0, node_path_1.join)(root, 'dist') });
|
|
93
|
+
const tarball = (0, node_fs_1.readFileSync)((0, node_path_1.join)(root, 'dist', `${name}.tar.gz`));
|
|
94
|
+
const sums = `${(0, node_crypto_1.createHash)('sha256').update(tarball).digest('hex')} ${name}.tar.gz\n`;
|
|
95
|
+
mirror = (0, node_http_1.createServer)((request, response) => {
|
|
96
|
+
if (request.url === '/latest-v22.x/SHASUMS256.txt') {
|
|
97
|
+
response.end(sums);
|
|
98
|
+
}
|
|
99
|
+
else if (request.url === `/latest-v22.x/${name}.tar.gz`) {
|
|
100
|
+
response.end(tarball);
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
response.writeHead(404).end();
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
await new Promise(resolve => mirror.listen(0, '127.0.0.1', resolve));
|
|
107
|
+
mirrorUrl = `http://127.0.0.1:${mirror.address().port}`;
|
|
108
|
+
});
|
|
109
|
+
(0, bun_test_1.afterAll)(async () => {
|
|
110
|
+
await Promise.all(hosts.map(created => created.dispose()));
|
|
111
|
+
mirror.close();
|
|
112
|
+
delete process.env.FAKE_SSH_PASSWORD;
|
|
113
|
+
});
|
|
114
|
+
(0, bun_test_1.it)('copies its server once, and runs commands there with the Node.js of the host', async () => {
|
|
115
|
+
var _a;
|
|
116
|
+
const home = remote('with-node', `${(0, node_path_1.join)(node, '..')}:/usr/bin:/bin`);
|
|
117
|
+
steps.length = 0;
|
|
118
|
+
const first = host();
|
|
119
|
+
const env = new remote_exec_environment_1.RemoteExecEnvironment(first.client, home);
|
|
120
|
+
const chunks = [];
|
|
121
|
+
(0, bun_test_1.expect)((await env.exec('pwd; echo "$HOME"', { onData: data => chunks.push(data) })).exitCode).toBe(0);
|
|
122
|
+
(0, bun_test_1.expect)(Buffer.concat(chunks).toString()).toBe(`${home}\n${home}\n`);
|
|
123
|
+
(0, bun_test_1.expect)(steps).toEqual(['connecting', 'checking', 'copying-server', 'starting']);
|
|
124
|
+
(0, bun_test_1.expect)((await first.client.info()).cwd).toBe((0, node_fs_1.realpathSync)(home));
|
|
125
|
+
await first.dispose();
|
|
126
|
+
(0, bun_test_1.expect)((0, node_fs_1.existsSync)((0, node_path_1.join)(root, 'master'))).toBe(false);
|
|
127
|
+
steps.length = 0;
|
|
128
|
+
const second = host();
|
|
129
|
+
(0, bun_test_1.expect)((_a = (await new remote_exec_environment_1.RemoteExecEnvironment(second.client, home).stat('.'))) === null || _a === void 0 ? void 0 : _a.isDirectory).toBe(true);
|
|
130
|
+
(0, bun_test_1.expect)(steps).toEqual(['connecting', 'checking', 'starting']);
|
|
131
|
+
await second.dispose();
|
|
132
|
+
});
|
|
133
|
+
(0, bun_test_1.it)('installs Node.js on a host without one, from the mirror, checked', async () => {
|
|
134
|
+
const home = remote('without-node', bare);
|
|
135
|
+
steps.length = 0;
|
|
136
|
+
const created = host();
|
|
137
|
+
const env = new remote_exec_environment_1.RemoteExecEnvironment(created.client, home);
|
|
138
|
+
(0, bun_test_1.expect)((await env.exec('true')).exitCode).toBe(0);
|
|
139
|
+
(0, bun_test_1.expect)(steps).toEqual(['connecting', 'checking', 'installing-node', 'installing-node', 'copying-server', 'starting']);
|
|
140
|
+
(0, bun_test_1.expect)((0, node_fs_1.existsSync)((0, node_path_1.join)(home, '.ta/server/node/bin/node'))).toBe(true);
|
|
141
|
+
await created.dispose();
|
|
142
|
+
});
|
|
143
|
+
(0, bun_test_1.it)('asks for the password through Ta, and fails with what ssh said when it is wrong', async () => {
|
|
144
|
+
remote('password', `${(0, node_path_1.join)(node, '..')}:/usr/bin:/bin`);
|
|
145
|
+
process.env.FAKE_SSH_PASSWORD = 's3cret';
|
|
146
|
+
try {
|
|
147
|
+
const questions = [];
|
|
148
|
+
const right = host({
|
|
149
|
+
ask: async (question) => {
|
|
150
|
+
questions.push(`${question.kind}:${question.message}`);
|
|
151
|
+
return 's3cret';
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
await right.client.info();
|
|
155
|
+
(0, bun_test_1.expect)(questions).toEqual(["secret:fake's password:"]);
|
|
156
|
+
await right.dispose();
|
|
157
|
+
const wrong = host({ ask: async () => 'nope' });
|
|
158
|
+
await (0, bun_test_1.expect)(wrong.client.info()).rejects.toThrow('Permission denied (password).');
|
|
159
|
+
const cancelled = host({ ask: async () => undefined });
|
|
160
|
+
await (0, bun_test_1.expect)(cancelled.client.info()).rejects.toThrow('Permission denied (cancelled).');
|
|
161
|
+
}
|
|
162
|
+
finally {
|
|
163
|
+
delete process.env.FAKE_SSH_PASSWORD;
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
(0, bun_test_1.it)('says the connection was lost when ssh ends', async () => {
|
|
167
|
+
const home = remote('lost', `${(0, node_path_1.join)(node, '..')}:/usr/bin:/bin`);
|
|
168
|
+
const created = host();
|
|
169
|
+
const env = new remote_exec_environment_1.RemoteExecEnvironment(created.client, home);
|
|
170
|
+
// Connected first: a first connection can take longer than the wait below, and then there would be
|
|
171
|
+
// no server to end yet.
|
|
172
|
+
await created.client.info();
|
|
173
|
+
const running = env.exec('sleep 30');
|
|
174
|
+
await new Promise(resolve => setTimeout(resolve, 300));
|
|
175
|
+
// Not through a shell, whose command line would match too.
|
|
176
|
+
(0, node_child_process_1.spawnSync)('pkill', ['-f', `${home}/.ta/server`]);
|
|
177
|
+
await (0, bun_test_1.expect)(running).rejects.toThrow(/lost/);
|
|
178
|
+
(0, bun_test_1.expect)(created.client.connected).toBe(false);
|
|
179
|
+
(0, bun_test_1.expect)((await env.exec('true')).exitCode).toBe(0);
|
|
180
|
+
});
|
|
181
|
+
});
|
|
182
|
+
//# sourceMappingURL=ssh-host.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh-host.spec.js","sourceRoot":"","sources":["../../../src/node/ssh/ssh-host.spec.ts"],"names":[],"mappings":";;AAAA,uCAAqE;AACrE,2DAA6D;AAC7D,6CAAyC;AACzC,qCAAqH;AACrH,yCAAsD;AACtD,qCAAiC;AACjC,yCAAiC;AACjC,wEAAmE;AACnE,yCAAwE;AACxE,yCAAqC;AAErC;;;;GAIG;AACH,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BhB,CAAC;AAEF;;;GAGG;AACH,MAAM,QAAQ,GAAG;;;CAGhB,CAAC;AAEF,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,EAAE,CAC3B,IAAA,iCAAY,EAAC,SAAS,EAAE,CAAC,IAAI,EAAE,cAAc,IAAI,UAAU,CAAC,CAAC;KACxD,QAAQ,EAAE;KACV,IAAI,EAAE,CAAC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C,MAAM,CAAC,SAAS,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAC7C,IAAA,iBAAM,EAAC,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** What ssh asks while it connects, for a person to answer. */
|
|
2
|
+
export interface SshQuestion {
|
|
3
|
+
/** `confirm`: answered `yes` or `no` (a new host key); `secret`: not shown as typed. */
|
|
4
|
+
kind: 'secret' | 'confirm' | 'text';
|
|
5
|
+
message: string;
|
|
6
|
+
}
|
|
7
|
+
/** What a host has, as the probe script prints it. */
|
|
8
|
+
export interface SshProbe {
|
|
9
|
+
home: string;
|
|
10
|
+
os: string;
|
|
11
|
+
arch: string;
|
|
12
|
+
/** A Node.js of version 18 or later; none when it has none. */
|
|
13
|
+
node?: string;
|
|
14
|
+
musl: boolean;
|
|
15
|
+
/** The server of this version is there already. */
|
|
16
|
+
server: boolean;
|
|
17
|
+
}
|
|
18
|
+
/** The pure parts of SshHost: arguments, scripts, and what comes back. */
|
|
19
|
+
export declare namespace SshUtil {
|
|
20
|
+
/** Where Ta keeps its server and Node.js on a host, under its home directory. */
|
|
21
|
+
const REMOTE_DIR = ".ta/server";
|
|
22
|
+
const MIN_NODE_MAJOR = 18;
|
|
23
|
+
/** One argument for a POSIX shell (and for fish, whose single quotes read `\'` the same way here). */
|
|
24
|
+
function quote(value: string): string;
|
|
25
|
+
/** What ssh takes for the host of a location: `ssh://user@host:port` when it names a port. */
|
|
26
|
+
function destination(host: string): string;
|
|
27
|
+
/** The command line ssh runs on the host: `script` in a POSIX shell, whatever the user's shell is. */
|
|
28
|
+
function remoteCommand(script: string, ...args: string[]): string;
|
|
29
|
+
function question(prompt: string): SshQuestion;
|
|
30
|
+
/** Looks at the host: its system, a Node.js to use, and whether the server of `hash` is there. */
|
|
31
|
+
function probeScript(hash: string): string;
|
|
32
|
+
/** undefined when the output is not the probe's: the host has no POSIX shell. */
|
|
33
|
+
function parseProbe(output: string): SshProbe | undefined;
|
|
34
|
+
/** Writes the standard input to `file` under the remote directory, whole or not at all. */
|
|
35
|
+
function uploadScript(file: string): string;
|
|
36
|
+
/** Unpacks the .tar.gz of Node.js on the standard input as node/ of the remote directory. */
|
|
37
|
+
function installNodeScript(): string;
|
|
38
|
+
/**
|
|
39
|
+
* Starts the server (`$2`, a script) with Node.js (`$1`) in the home directory, in a login shell of the
|
|
40
|
+
* user when it is a POSIX one, so that commands find what the user's profile puts on PATH.
|
|
41
|
+
*/
|
|
42
|
+
function launchScript(): string;
|
|
43
|
+
/** The build of Node.js for a host, as nodejs.org names them; undefined when there is none. */
|
|
44
|
+
function nodePlatform(os: string, arch: string): string | undefined;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=ssh-util.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ssh-util.d.ts","sourceRoot":"","sources":["../../../src/node/ssh/ssh-util.ts"],"names":[],"mappings":"AAAA,+DAA+D;AAC/D,MAAM,WAAW,WAAW;IACxB,wFAAwF;IACxF,IAAI,EAAE,QAAQ,GAAG,SAAS,GAAG,MAAM,CAAC;IACpC,OAAO,EAAE,MAAM,CAAC;CACnB;AAED,sDAAsD;AACtD,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,OAAO,CAAC;IACd,mDAAmD;IACnD,MAAM,EAAE,OAAO,CAAC;CACnB;AAED,0EAA0E;AAC1E,yBAAiB,OAAO,CAAC;IACrB,iFAAiF;IAC1E,MAAM,UAAU,eAAe,CAAC;IAChC,MAAM,cAAc,K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