Skip to content

Commit 99d38d5

Browse files
more fixes
1 parent 44bb498 commit 99d38d5

File tree

5 files changed

+20
-10
lines changed

5 files changed

+20
-10
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@codesandbox/sdk",
3-
"version": "2.0.0-rc.10-debug",
3+
"version": "2.0.0-rc.11-debug.2",
44
"description": "The CodeSandbox SDK",
55
"author": "CodeSandbox",
66
"license": "MIT",

src/SandboxClient/commands.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ export type CommandStatus =
2727

2828
const DEFAULT_SHELL_SIZE = { cols: 128, rows: 24 };
2929

30-
export class Commands {
30+
// This can not be called Commands due to React Native
31+
export class SandboxCommands {
3132
private disposable = new Disposable();
3233
constructor(
3334
sessionDisposable: Disposable,

src/SandboxClient/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { Setup } from "./setup";
66
import { Tasks } from "./tasks";
77
import { Interpreters } from "./interpreters";
88
import { Terminals } from "./terminals";
9-
import { Commands } from "./commands";
9+
import { SandboxCommands } from "./commands";
1010
import { HostToken } from "../HostTokens";
1111
import { Hosts } from "./hosts";
1212
import { IAgentClient } from "../node/agent-client-interface";
@@ -80,7 +80,7 @@ export class SandboxClient {
8080
/**
8181
* Namespace for running commands in the Sandbox
8282
*/
83-
public readonly commands: Commands;
83+
public readonly commands: SandboxCommands;
8484

8585
/**
8686
* Namespace for running code interpreters in the Sandbox
@@ -121,7 +121,7 @@ export class SandboxClient {
121121
);
122122
this.fs = new FileSystem(this.disposable, this.agentClient, username);
123123
this.terminals = new Terminals(this.disposable, this.agentClient);
124-
this.commands = new Commands(this.disposable, this.agentClient);
124+
this.commands = new SandboxCommands(this.disposable, this.agentClient);
125125

126126
this.hosts = new Hosts(this.agentClient.sandboxId, hostToken);
127127
this.interpreters = new Interpreters(this.disposable, this.commands);

src/SandboxClient/interpreters.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
import { Disposable } from "../utils/disposable";
2-
import { Commands, ShellRunOpts } from "./commands";
2+
import { SandboxCommands, ShellRunOpts } from "./commands";
33

44
export class Interpreters {
55
private disposable = new Disposable();
6-
constructor(sessionDisposable: Disposable, private commands: Commands) {
6+
constructor(
7+
sessionDisposable: Disposable,
8+
private commands: SandboxCommands
9+
) {
710
sessionDisposable.onWillDispose(() => {
811
this.disposable.dispose();
912
});

src/bin/commands/build.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { promises as fs } from "fs";
2-
import path from "path";
2+
import path, { dirname } from "path";
33
import * as readline from "readline";
44
import { type Client } from "@hey-api/client-fetch";
55
import ora from "ora";
@@ -20,6 +20,7 @@ import {
2020
import { getInferredApiKey } from "../../utils/constants";
2121
import { hashDirectory } from "../utils/hash";
2222
import { startVm } from "../../Sandboxes";
23+
import { mkdir, writeFile } from "fs/promises";
2324

2425
export type BuildCommandArgs = {
2526
directory: string;
@@ -35,6 +36,11 @@ export type BuildCommandArgs = {
3536
logPath?: string;
3637
};
3738

39+
async function writeFileEnsureDir(filePath, data) {
40+
await mkdir(dirname(filePath), { recursive: true });
41+
await writeFile(filePath, data);
42+
}
43+
3844
function stripAnsiCodes(str: string) {
3945
// Matches ESC [ params … finalChar
4046
// \x1B = ESC
@@ -172,11 +178,11 @@ export const buildCommand: yargs.CommandModule<
172178
const timestamp = new Date().toISOString().replace(/:/g, "-");
173179
const logFilename = path.join(
174180
logPath,
175-
`setup-failure-${step.name}-${timestamp}.log`
181+
`setup-failure-${sandbox.id}-${timestamp}.log`
176182
);
177183

178184
try {
179-
await fs.writeFile(logFilename, buffer.join("\n"));
185+
await writeFileEnsureDir(logFilename, buffer.join("\n"));
180186
console.error(`Log saved to: ${logFilename}`);
181187
} catch (writeError) {
182188
console.error(`Failed to write log file: ${writeError}`);

0 commit comments

Comments
 (0)