Skip to content

Commit faeeb78

Browse files
authored
Skip cache before image in TypeScript (#937)
<!-- CURSOR_SUMMARY --> > [!NOTE] > Adjusts `skipCache` to return `this` in types and aligns implementation for proper fluent chaining. > > - **JS SDK – `template`**: > - **Types**: Change `skipCache` return type from `TemplateBuilder` to `this` in `types.ts` (`TemplateFromImage`, `TemplateBuilder`). > - **Implementation**: Align `skipCache` in `index.ts` by removing explicit return type annotation to match `this` chaining. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 58131d1. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 66ee6df commit faeeb78

File tree

6 files changed

+40
-4
lines changed

6 files changed

+40
-4
lines changed

.changeset/selfish-poets-heal.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'e2b': patch
3+
---
4+
5+
fixes skipCache type

packages/js-sdk/src/template/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ export class TemplateBase
498498
return this
499499
}
500500

501-
skipCache(): TemplateBuilder {
501+
skipCache(): this {
502502
this.forceNextLayer = true
503503
return this
504504
}

packages/js-sdk/src/template/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ export interface TemplateFromImage {
4646

4747
fromTemplate(template: string): TemplateBuilder
4848

49-
fromDockerfile(dockerfileContent: string): TemplateBuilder
49+
fromDockerfile(dockerfileContentOrPath: string): TemplateBuilder
5050

5151
fromAWSRegistry(
5252
image: string,
@@ -64,7 +64,7 @@ export interface TemplateFromImage {
6464
}
6565
): TemplateBuilder
6666

67-
skipCache(): TemplateBuilder
67+
skipCache(): this
6868
}
6969

7070
// Interface for the main builder state
@@ -130,7 +130,7 @@ export interface TemplateBuilder {
130130

131131
setEnvs(envs: Record<string, string>): TemplateBuilder
132132

133-
skipCache(): TemplateBuilder
133+
skipCache(): this
134134

135135
setStartCmd(
136136
startCommand: string,

packages/js-sdk/tests/template/build.test.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,12 @@ buildTemplateTest(
7070
await buildTemplate(template)
7171
}
7272
)
73+
74+
buildTemplateTest(
75+
'build template with skipCache',
76+
{ timeout: 180000 },
77+
async ({ buildTemplate }) => {
78+
const template = Template().skipCache().fromImage('ubuntu:22.04')
79+
await buildTemplate(template)
80+
}
81+
)

packages/python-sdk/tests/async/template_async/test_build.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,14 @@ async def test_build_template_with_resolve_symlinks(async_build, setup_test_fold
8181
)
8282

8383
await async_build(template)
84+
85+
86+
@pytest.mark.skip_debug()
87+
async def test_build_template_with_skip_cache(async_build, setup_test_folder):
88+
template = (
89+
AsyncTemplate(file_context_path=setup_test_folder)
90+
.skip_cache()
91+
.from_image("ubuntu:22.04")
92+
)
93+
94+
await async_build(template)

packages/python-sdk/tests/sync/template_sync/test_build.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,14 @@ def test_build_template_with_resolve_symlinks(build, setup_test_folder):
8181
)
8282

8383
build(template)
84+
85+
86+
@pytest.mark.skip_debug()
87+
def test_build_template_with_skip_cache(build, setup_test_folder):
88+
template = (
89+
Template(file_context_path=setup_test_folder)
90+
.skip_cache()
91+
.from_image("ubuntu:22.04")
92+
)
93+
94+
build(template)

0 commit comments

Comments
 (0)