Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openrouter/spawn",
"version": "0.27.6",
"version": "0.27.7",
"type": "module",
"bin": {
"spawn": "cli.js"
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/aws/aws.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1178,15 +1178,15 @@ export async function uploadFile(localPath: string, remotePath: string): Promise
}

export async function downloadFile(remotePath: string, localPath: string): Promise<void> {
const normalizedRemote = validateRemotePath(remotePath, /^[a-zA-Z0-9/_.~$-]+$/);
const expandedRemote = remotePath.replace(/^\$HOME\//, "~/");
const normalizedRemote = validateRemotePath(expandedRemote, /^[a-zA-Z0-9/_.~-]+$/);
const keyOpts = getSshKeyOpts(await ensureSshKeys());
const expandedPath = normalizedRemote.replace(/^\$HOME/, "~");
const proc = Bun.spawn(
[
"scp",
...SSH_BASE_OPTS,
...keyOpts,
`${SSH_USER}@${_state.instanceIp}:${expandedPath}`,
`${SSH_USER}@${_state.instanceIp}:${normalizedRemote}`,
localPath,
],
{
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/digitalocean/digitalocean.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1448,17 +1448,17 @@ export async function uploadFile(localPath: string, remotePath: string, ip?: str

export async function downloadFile(remotePath: string, localPath: string, ip?: string): Promise<void> {
const serverIp = ip || _state.serverIp;
const normalizedRemote = validateRemotePath(remotePath, /^[a-zA-Z0-9/_.~$-]+$/);
const expandedRemote = remotePath.replace(/^\$HOME\//, "~/");
const normalizedRemote = validateRemotePath(expandedRemote, /^[a-zA-Z0-9/_.~-]+$/);

const keyOpts = getSshKeyOpts(await ensureSshKeys());
const expandedPath = normalizedRemote.replace(/^\$HOME/, "~");

const proc = Bun.spawn(
[
"scp",
...SSH_BASE_OPTS,
...keyOpts,
`root@${serverIp}:${expandedPath}`,
`root@${serverIp}:${normalizedRemote}`,
localPath,
],
{
Expand Down
13 changes: 6 additions & 7 deletions packages/cli/src/gcp/gcp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1028,10 +1028,9 @@ export async function uploadFile(localPath: string, remotePath: string): Promise
logError(`Invalid local path: ${localPath}`);
throw new Error("Invalid local path");
}
const normalizedRemote = validateRemotePath(remotePath, /^[a-zA-Z0-9/_.~$-]+$/);
const expandedRemote = remotePath.replace(/^\$HOME\//, "~/");
const normalizedRemote = validateRemotePath(expandedRemote, /^[a-zA-Z0-9/_.~-]+$/);
const username = resolveUsername();
// Expand $HOME on remote side
const expandedPath = normalizedRemote.replace(/^\$HOME/, "~");
const keyOpts = getSshKeyOpts(await ensureSshKeys());

const proc = Bun.spawn(
Expand All @@ -1040,7 +1039,7 @@ export async function uploadFile(localPath: string, remotePath: string): Promise
...SSH_BASE_OPTS,
...keyOpts,
localPath,
`${username}@${_state.serverIp}:${expandedPath}`,
`${username}@${_state.serverIp}:${normalizedRemote}`,
],
{
stdio: [
Expand All @@ -1067,17 +1066,17 @@ export async function downloadFile(remotePath: string, localPath: string): Promi
logError(`Invalid local path: ${localPath}`);
throw new Error("Invalid local path");
}
const normalizedRemote = validateRemotePath(remotePath, /^[a-zA-Z0-9/_.~$-]+$/);
const expandedRemote = remotePath.replace(/^\$HOME\//, "~/");
const normalizedRemote = validateRemotePath(expandedRemote, /^[a-zA-Z0-9/_.~-]+$/);
const username = resolveUsername();
const expandedPath = normalizedRemote.replace(/^\$HOME/, "~");
const keyOpts = getSshKeyOpts(await ensureSshKeys());

const proc = Bun.spawn(
[
"scp",
...SSH_BASE_OPTS,
...keyOpts,
`${username}@${_state.serverIp}:${expandedPath}`,
`${username}@${_state.serverIp}:${normalizedRemote}`,
localPath,
],
{
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/hetzner/hetzner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -909,17 +909,17 @@ export async function uploadFile(localPath: string, remotePath: string, ip?: str

export async function downloadFile(remotePath: string, localPath: string, ip?: string): Promise<void> {
const serverIp = ip || _state.serverIp;
const normalizedRemote = validateRemotePath(remotePath, /^[a-zA-Z0-9/_.~$-]+$/);
const expandedRemote = remotePath.replace(/^\$HOME\//, "~/");
const normalizedRemote = validateRemotePath(expandedRemote, /^[a-zA-Z0-9/_.~-]+$/);

const keyOpts = getSshKeyOpts(await ensureSshKeys());
const expandedPath = normalizedRemote.replace(/^\$HOME/, "~");

const proc = Bun.spawn(
[
"scp",
...SSH_BASE_OPTS,
...keyOpts,
`root@${serverIp}:${expandedPath}`,
`root@${serverIp}:${normalizedRemote}`,
localPath,
],
{
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/sprite/sprite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -657,10 +657,10 @@ export async function uploadFileSprite(localPath: string, remotePath: string): P

/** Download a file from the remote sprite by catting it to stdout. */
export async function downloadFileSprite(remotePath: string, localPath: string): Promise<void> {
const normalizedRemote = validateRemotePath(remotePath, /^[a-zA-Z0-9/_.~$-]+$/);
const expandedRemote = remotePath.replace(/^\$HOME\//, "~/");
const normalizedRemote = validateRemotePath(expandedRemote, /^[a-zA-Z0-9/_.~-]+$/);

const spriteCmd = getSpriteCmd()!;
const expandedPath = normalizedRemote.replace(/^\$HOME/, "~");

await spriteRetry("sprite download", async () => {
const proc = Bun.spawn(
Expand All @@ -672,7 +672,7 @@ export async function downloadFileSprite(remotePath: string, localPath: string):
_state.name,
"--",
"cat",
expandedPath,
normalizedRemote,
],
{
stdio: [
Expand Down
Loading