Skip to content

Commit e334e4e

Browse files
merge
2 parents c478800 + da518c9 commit e334e4e

File tree

4 files changed

+31
-12
lines changed

4 files changed

+31
-12
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": "1.1.3",
3+
"version": "1.1.4",
44
"description": "The CodeSandbox SDK",
55
"author": "CodeSandbox",
66
"license": "MIT",

src/bin/commands/build.ts

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,15 @@ export const buildCommand: yargs.CommandModule<
108108

109109
const sandboxIds = await Promise.all(
110110
clusters.map(async ({ host: cluster, slug }, index) => {
111+
const clusterApiClient: Client = createClient(
112+
createConfig({
113+
baseUrl: BASE_URL,
114+
headers: {
115+
Authorization: `Bearer ${API_KEY}`,
116+
"x-pitcher-manager-url": `https://${cluster}/api/v1`,
117+
},
118+
})
119+
);
111120
const sdk = new CodeSandbox(API_KEY, {
112121
baseUrl: BASE_URL,
113122
headers: {
@@ -126,7 +135,7 @@ export const buildCommand: yargs.CommandModule<
126135

127136
spinner.start(updateSpinnerMessage(index, "Creating sandbox..."));
128137
sandboxId = await createSandbox({
129-
apiClient,
138+
apiClient: clusterApiClient,
130139
shaTag: tag,
131140
fromSandbox: argv.fromSandbox,
132141
collectionPath: argv.path,
@@ -140,10 +149,14 @@ export const buildCommand: yargs.CommandModule<
140149
updateSpinnerMessage(index, "Starting sandbox...", sandboxId)
141150
);
142151

143-
const startResponse = await startVm(apiClient, sandboxId, {
152+
const startResponse = await startVm(clusterApiClient, sandboxId, {
144153
vmTier: VMTier.fromName("Micro"),
145154
});
146-
let sandbox = new Sandbox(sandboxId, apiClient, startResponse);
155+
let sandbox = new Sandbox(
156+
sandboxId,
157+
clusterApiClient,
158+
startResponse
159+
);
147160
let session = await sandbox.connect();
148161

149162
spinner.start(

src/sessions/WebSocketSession/commands.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,19 +64,25 @@ export class Commands {
6464
true
6565
);
6666

67+
if (shell.status === "ERROR" || shell.status === "KILLED") {
68+
throw new Error(`Failed to create shell: ${shell.buffer.join("\n")}`);
69+
}
70+
6771
const details = {
6872
type: "command",
6973
command,
7074
name: opts?.name,
7175
};
7276

73-
// Only way for us to differentiate between a command and a terminal
74-
this.pitcherClient.clients.shell.rename(
75-
shell.shellId,
76-
// We embed some details in the name to properly show the command that was run
77-
// , the name and that it is an actual command
78-
JSON.stringify(details)
79-
);
77+
if (shell.status !== "FINISHED") {
78+
// Only way for us to differentiate between a command and a terminal
79+
this.pitcherClient.clients.shell.rename(
80+
shell.shellId,
81+
// We embed some details in the name to properly show the command that was run
82+
// , the name and that it is an actual command
83+
JSON.stringify(details)
84+
);
85+
}
8086

8187
const cmd = new Command(
8288
this.pitcherClient,

src/utils/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ export function getDefaultTemplateId(apiClient: Client): string {
5656
return "7ngcrf";
5757
}
5858

59-
return "pcz35m";
59+
return "pt_UAYyadeQTA9jw8bXqzgy6v";
6060
}
6161

6262
export function handleResponse<D, E>(

0 commit comments

Comments
 (0)