replicas-cli 0.2.172 → 0.2.173

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.
Files changed (2) hide show
  1. package/dist/index.mjs +22 -10
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -7842,9 +7842,9 @@ import chalk5 from "chalk";
7842
7842
  // src/lib/ssh.ts
7843
7843
  import { spawn } from "child_process";
7844
7844
  var SSH_OPTIONS = ["-o", "StrictHostKeyChecking=no", "-o", "UserKnownHostsFile=/dev/null"];
7845
- async function connectSSH(token, host) {
7845
+ async function connectSSH(token, host, proxyCommand) {
7846
7846
  return new Promise((resolve, reject) => {
7847
- const sshArgs = [...SSH_OPTIONS, `${token}@${host}`];
7847
+ const sshArgs = proxyCommand ? [...SSH_OPTIONS, "-o", `ProxyCommand=${proxyCommand}`, `${token}@${host}`] : [...SSH_OPTIONS, `${token}@${host}`];
7848
7848
  const ssh = spawn("ssh", sshArgs, {
7849
7849
  stdio: "inherit"
7850
7850
  });
@@ -7949,6 +7949,7 @@ Found ${response.workspaces.length} workspaces matching "${workspaceName}":`));
7949
7949
  workspace: selectedWorkspace,
7950
7950
  sshToken: tokenResponse.token,
7951
7951
  sshHost: tokenResponse.host,
7952
+ sshProxyCommand: tokenResponse.proxyCommand,
7952
7953
  repoName
7953
7954
  };
7954
7955
  }
@@ -7960,13 +7961,13 @@ async function connectCommand(workspaceName) {
7960
7961
  process.exit(1);
7961
7962
  }
7962
7963
  try {
7963
- const { workspace, sshToken, sshHost } = await prepareWorkspaceConnection(workspaceName);
7964
+ const { workspace, sshToken, sshHost, sshProxyCommand } = await prepareWorkspaceConnection(workspaceName);
7964
7965
  console.log(chalk5.blue(`
7965
7966
  Connecting to ${workspace.name}...`));
7966
7967
  const sshCommand = `ssh ${sshToken}@${sshHost}`;
7967
7968
  console.log(chalk5.gray(`SSH command: ${sshCommand}`));
7968
7969
  console.log(chalk5.gray("\nPress Ctrl+D to disconnect.\n"));
7969
- await connectSSH(sshToken, sshHost);
7970
+ await connectSSH(sshToken, sshHost, sshProxyCommand);
7970
7971
  console.log(chalk5.green("\n\u2713 Disconnected from workspace.\n"));
7971
7972
  } catch (error) {
7972
7973
  console.error(chalk5.red(`
@@ -9298,15 +9299,25 @@ function writeSSHConfig(content) {
9298
9299
  ensureSSHDir();
9299
9300
  fs2.writeFileSync(SSH_CONFIG_PATH, content, { mode: 384 });
9300
9301
  }
9302
+ function sanitizeSSHConfigValue(value) {
9303
+ return value.replace(/[\r\n]+/g, " ").trim();
9304
+ }
9301
9305
  function generateConfigBlock(entry) {
9306
+ const host = sanitizeSSHConfigValue(entry.host);
9307
+ const hostname = sanitizeSSHConfigValue(entry.hostname);
9308
+ const user = sanitizeSSHConfigValue(entry.user);
9309
+ const proxyCommand = entry.proxyCommand ? sanitizeSSHConfigValue(entry.proxyCommand) : void 0;
9302
9310
  const lines = [
9303
9311
  REPLICAS_MARKER_START,
9304
- `Host ${entry.host}`,
9305
- ` HostName ${entry.hostname}`,
9306
- ` User ${entry.user}`,
9312
+ `Host ${host}`,
9313
+ ` HostName ${hostname}`,
9314
+ ` User ${user}`,
9307
9315
  ` StrictHostKeyChecking no`,
9308
9316
  ` UserKnownHostsFile /dev/null`
9309
9317
  ];
9318
+ if (proxyCommand) {
9319
+ lines.push(` ProxyCommand ${proxyCommand}`);
9320
+ }
9310
9321
  lines.push(REPLICAS_MARKER_END);
9311
9322
  return lines.join("\n");
9312
9323
  }
@@ -9359,13 +9370,14 @@ async function codeCommand(workspaceName) {
9359
9370
  process.exit(1);
9360
9371
  }
9361
9372
  try {
9362
- const { workspace, sshToken, sshHost, repoName } = await prepareWorkspaceConnection(workspaceName);
9373
+ const { workspace, sshToken, sshHost, sshProxyCommand, repoName } = await prepareWorkspaceConnection(workspaceName);
9363
9374
  const hostAlias = getWorkspaceHostAlias(workspace.name);
9364
9375
  console.log(chalk6.blue("\nConfiguring SSH connection..."));
9365
9376
  addOrUpdateSSHConfigEntry({
9366
9377
  host: hostAlias,
9367
9378
  hostname: sshHost,
9368
- user: sshToken
9379
+ user: sshToken,
9380
+ proxyCommand: sshProxyCommand
9369
9381
  });
9370
9382
  console.log(chalk6.green(`\u2713 SSH config entry created: ${hostAlias}`));
9371
9383
  const remotePath = repoName ? `${SANDBOX_PATHS.WORKSPACES_DIR}/${repoName}` : SANDBOX_PATHS.HOME_DIR;
@@ -14811,7 +14823,7 @@ Deleted file ${pathOrId}.
14811
14823
  }
14812
14824
 
14813
14825
  // src/index.ts
14814
- var CLI_VERSION = "0.2.172";
14826
+ var CLI_VERSION = "0.2.173";
14815
14827
  function parseBooleanOption(value) {
14816
14828
  if (value === "true") return true;
14817
14829
  if (value === "false") return false;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-cli",
3
- "version": "0.2.172",
3
+ "version": "0.2.173",
4
4
  "description": "CLI for managing Replicas workspaces - SSH into cloud dev environments with automatic port forwarding",
5
5
  "main": "dist/index.mjs",
6
6
  "bin": {