@e2b/cli 2.2.3 → 2.2.5
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.
- package/dist/index.js +251 -220
- package/dist/index.js.map +1 -1
- package/dist/templates/python-build-sync.hbs +11 -10
- package/dist/templates/readme.hbs +89 -0
- package/dist/templates/typescript-build.hbs +13 -9
- package/package.json +3 -1
|
@@ -2,13 +2,14 @@ from e2b import Template
|
|
|
2
2
|
from template import template
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
{{
|
|
9
|
-
|
|
10
|
-
{{
|
|
11
|
-
{{
|
|
12
|
-
|
|
13
|
-
{{
|
|
14
|
-
|
|
5
|
+
if __name__ == "__main__":
|
|
6
|
+
Template.build(
|
|
7
|
+
template,
|
|
8
|
+
alias="{{alias}}",
|
|
9
|
+
{{#if cpuCount}}
|
|
10
|
+
cpu_count={{cpuCount}},
|
|
11
|
+
{{/if}}
|
|
12
|
+
{{#if memoryMB}}
|
|
13
|
+
memory_mb={{memoryMB}},
|
|
14
|
+
{{/if}}
|
|
15
|
+
)
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# {{alias}} - E2B Sandbox Template
|
|
2
|
+
|
|
3
|
+
This is an E2B sandbox template that allows you to run code in a controlled environment.
|
|
4
|
+
|
|
5
|
+
## Prerequisites
|
|
6
|
+
|
|
7
|
+
Before you begin, make sure you have:
|
|
8
|
+
- An E2B account (sign up at [e2b.dev](https://e2b.dev))
|
|
9
|
+
- Your E2B API key (get it from your [E2B dashboard](https://e2b.dev/dashboard))
|
|
10
|
+
{{#if isTypeScript}}- Node.js and npm/yarn (or similar) installed{{else if isPython}}- Python installed{{/if}}
|
|
11
|
+
|
|
12
|
+
## Configuration
|
|
13
|
+
|
|
14
|
+
1. Create a `.env` file in your project root or set the environment variable:
|
|
15
|
+
```
|
|
16
|
+
E2B_API_KEY=your_api_key_here
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Building the Template
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
{{#if isTypeScript}}
|
|
23
|
+
# For development
|
|
24
|
+
npm run e2b:build:dev
|
|
25
|
+
|
|
26
|
+
# For production
|
|
27
|
+
npm run e2b:build:prod
|
|
28
|
+
{{else if isPython}}
|
|
29
|
+
# For development
|
|
30
|
+
make e2b:build:dev
|
|
31
|
+
|
|
32
|
+
# For production
|
|
33
|
+
make e2b:build:prod
|
|
34
|
+
{{/if}}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Using the Template in a Sandbox
|
|
38
|
+
|
|
39
|
+
Once your template is built, you can use it in your E2B sandbox:
|
|
40
|
+
|
|
41
|
+
{{#if isTypeScript}}
|
|
42
|
+
```typescript
|
|
43
|
+
import { Sandbox } from 'e2b'
|
|
44
|
+
|
|
45
|
+
// Create a new sandbox instance
|
|
46
|
+
const sandbox = await Sandbox.create('{{alias}}')
|
|
47
|
+
|
|
48
|
+
// Your sandbox is ready to use!
|
|
49
|
+
console.log('Sandbox created successfully')
|
|
50
|
+
```
|
|
51
|
+
{{else if isPythonSync}}
|
|
52
|
+
```python
|
|
53
|
+
from e2b import Sandbox
|
|
54
|
+
|
|
55
|
+
# Create a new sandbox instance
|
|
56
|
+
sandbox = Sandbox.create('{{alias}}')
|
|
57
|
+
|
|
58
|
+
# Your sandbox is ready to use!
|
|
59
|
+
print('Sandbox created successfully')
|
|
60
|
+
```
|
|
61
|
+
{{else if isPythonAsync}}
|
|
62
|
+
```python
|
|
63
|
+
from e2b import AsyncSandbox
|
|
64
|
+
import asyncio
|
|
65
|
+
|
|
66
|
+
async def main():
|
|
67
|
+
# Create a new sandbox instance
|
|
68
|
+
sandbox = await AsyncSandbox.create('{{alias}}')
|
|
69
|
+
|
|
70
|
+
# Your sandbox is ready to use!
|
|
71
|
+
print('Sandbox created successfully')
|
|
72
|
+
|
|
73
|
+
# Run the async function
|
|
74
|
+
asyncio.run(main())
|
|
75
|
+
```
|
|
76
|
+
{{/if}}
|
|
77
|
+
|
|
78
|
+
## Template Structure
|
|
79
|
+
|
|
80
|
+
- `{{templateFile}}` - Defines the sandbox template configuration
|
|
81
|
+
- `{{buildDevFile}}` - Builds the template for development
|
|
82
|
+
- `{{buildProdFile}}` - Builds the template for production
|
|
83
|
+
|
|
84
|
+
## Next Steps
|
|
85
|
+
|
|
86
|
+
1. Customize the template in `{{templateFile}}` to fit your needs
|
|
87
|
+
2. Build the template using one of the methods above
|
|
88
|
+
3. Use the template in your E2B sandbox code
|
|
89
|
+
4. Check out the [E2B documentation](https://e2b.dev/docs) for more advanced usage
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import { Template } from 'e2b'
|
|
2
2
|
import { template } from './template'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
{{
|
|
7
|
-
|
|
8
|
-
{{
|
|
9
|
-
{{
|
|
10
|
-
|
|
11
|
-
{{
|
|
12
|
-
}
|
|
4
|
+
async function main() {
|
|
5
|
+
await Template.build(template, {
|
|
6
|
+
alias: '{{alias}}',
|
|
7
|
+
{{#if cpuCount}}
|
|
8
|
+
cpuCount: {{cpuCount}},
|
|
9
|
+
{{/if}}
|
|
10
|
+
{{#if memoryMB}}
|
|
11
|
+
memoryMB: {{memoryMB}},
|
|
12
|
+
{{/if}}
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
main().catch(console.error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e2b/cli",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.5",
|
|
4
4
|
"description": "CLI for managing e2b sandbox templates",
|
|
5
5
|
"homepage": "https://e2b.dev",
|
|
6
6
|
"license": "MIT",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"@types/inquirer": "^9.0.7",
|
|
41
41
|
"@types/json2md": "^1.5.4",
|
|
42
42
|
"@types/node": "^18.18.6",
|
|
43
|
+
"@types/npmcli__package-json": "^4.0.4",
|
|
43
44
|
"@types/statuses": "^2.0.5",
|
|
44
45
|
"@types/update-notifier": "6.0.5",
|
|
45
46
|
"@vitest/coverage-v8": "^3.2.4",
|
|
@@ -62,6 +63,7 @@
|
|
|
62
63
|
"dependencies": {
|
|
63
64
|
"@iarna/toml": "^2.2.5",
|
|
64
65
|
"@inquirer/prompts": "^5.5.0",
|
|
66
|
+
"@npmcli/package-json": "^5.2.1",
|
|
65
67
|
"async-listen": "^3.0.1",
|
|
66
68
|
"boxen": "^7.1.1",
|
|
67
69
|
"chalk": "^5.3.0",
|