@e2b/cli 2.2.0 → 2.2.2
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 +288 -167
- package/dist/index.js.map +1 -1
- package/dist/templates/python-build-async.hbs +20 -0
- package/dist/templates/python-build-sync.hbs +14 -0
- package/dist/templates/python-template.hbs +40 -0
- package/dist/templates/typescript-build.hbs +12 -0
- package/dist/templates/typescript-template.hbs +38 -0
- package/package.json +11 -3
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
from e2b import AsyncTemplate
|
|
3
|
+
from template import template
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
async def main():
|
|
7
|
+
await AsyncTemplate.build(
|
|
8
|
+
template,
|
|
9
|
+
alias="{{alias}}",
|
|
10
|
+
{{#if cpuCount}}
|
|
11
|
+
cpu_count={{cpuCount}},
|
|
12
|
+
{{/if}}
|
|
13
|
+
{{#if memoryMB}}
|
|
14
|
+
memory_mb={{memoryMB}},
|
|
15
|
+
{{/if}}
|
|
16
|
+
)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
if __name__ == "__main__":
|
|
20
|
+
asyncio.run(main())
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
from e2b import {{#if isAsync}}AsyncTemplate{{else}}Template{{/if}}
|
|
2
|
+
|
|
3
|
+
template = (
|
|
4
|
+
{{#if isAsync}}AsyncTemplate{{else}}Template{{/if}}()
|
|
5
|
+
{{#if fromImage}}
|
|
6
|
+
.from_image("{{{fromImage}}}")
|
|
7
|
+
{{/if}}
|
|
8
|
+
{{#each steps}}
|
|
9
|
+
{{#eq type "WORKDIR"}}
|
|
10
|
+
.set_workdir("{{{args.[0]}}}")
|
|
11
|
+
{{/eq}}
|
|
12
|
+
{{#eq type "USER"}}
|
|
13
|
+
.set_user("{{{args.[0]}}}")
|
|
14
|
+
{{/eq}}
|
|
15
|
+
{{#eq type "ENV"}}
|
|
16
|
+
.set_envs({
|
|
17
|
+
{{#each envVars}}
|
|
18
|
+
"{{{@key}}}": "{{{this}}}",
|
|
19
|
+
{{/each}}
|
|
20
|
+
})
|
|
21
|
+
{{/eq}}
|
|
22
|
+
{{#eq type "RUN"}}
|
|
23
|
+
.run_cmd("{{{args.[0]}}}")
|
|
24
|
+
{{/eq}}
|
|
25
|
+
{{#eq type "COPY"}}
|
|
26
|
+
.copy("{{{src}}}", "{{{dest}}}")
|
|
27
|
+
{{/eq}}
|
|
28
|
+
{{/each}}
|
|
29
|
+
{{#if startCmd}}
|
|
30
|
+
{{#if readyCmd}}
|
|
31
|
+
.set_user("root")
|
|
32
|
+
.set_workdir("/home/user")
|
|
33
|
+
.set_start_cmd("{{{escapeDoubleQuotes startCmd}}}", "{{{escapeDoubleQuotes readyCmd}}}")
|
|
34
|
+
{{/if}}
|
|
35
|
+
{{else if readyCmd}}
|
|
36
|
+
.set_user("root")
|
|
37
|
+
.set_workdir("/home/user")
|
|
38
|
+
.set_ready_cmd("{{{escapeDoubleQuotes readyCmd}}}")
|
|
39
|
+
{{/if}}
|
|
40
|
+
)
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Template } from 'e2b'
|
|
2
|
+
|
|
3
|
+
export const template = Template()
|
|
4
|
+
{{#if fromImage}}
|
|
5
|
+
.fromImage('{{{fromImage}}}')
|
|
6
|
+
{{/if}}
|
|
7
|
+
{{#each steps}}
|
|
8
|
+
{{#eq type "WORKDIR"}}
|
|
9
|
+
.setWorkdir('{{{args.[0]}}}')
|
|
10
|
+
{{/eq}}
|
|
11
|
+
{{#eq type "USER"}}
|
|
12
|
+
.setUser('{{{args.[0]}}}')
|
|
13
|
+
{{/eq}}
|
|
14
|
+
{{#eq type "ENV"}}
|
|
15
|
+
.setEnvs({
|
|
16
|
+
{{#each envVars}}
|
|
17
|
+
'{{{@key}}}': '{{{this}}}',
|
|
18
|
+
{{/each}}
|
|
19
|
+
})
|
|
20
|
+
{{/eq}}
|
|
21
|
+
{{#eq type "RUN"}}
|
|
22
|
+
.runCmd('{{{args.[0]}}}')
|
|
23
|
+
{{/eq}}
|
|
24
|
+
{{#eq type "COPY"}}
|
|
25
|
+
.copy('{{{src}}}', '{{{dest}}}')
|
|
26
|
+
{{/eq}}
|
|
27
|
+
{{/each}}
|
|
28
|
+
{{#if startCmd}}
|
|
29
|
+
{{#if readyCmd}}
|
|
30
|
+
.setUser('root')
|
|
31
|
+
.setWorkdir('/home/user')
|
|
32
|
+
.setStartCmd('{{{escapeQuotes startCmd}}}', '{{{escapeQuotes readyCmd}}}')
|
|
33
|
+
{{/if}}
|
|
34
|
+
{{else if readyCmd}}
|
|
35
|
+
.setUser('root')
|
|
36
|
+
.setWorkdir('/home/user')
|
|
37
|
+
.setReadyCmd('{{{escapeQuotes readyCmd}}}')
|
|
38
|
+
{{/if}}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@e2b/cli",
|
|
3
|
-
"version": "2.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "CLI for managing e2b sandbox templates",
|
|
5
5
|
"homepage": "https://e2b.dev",
|
|
6
6
|
"license": "MIT",
|
|
@@ -36,16 +36,19 @@
|
|
|
36
36
|
"sideEffects": false,
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/command-exists": "^1.2.3",
|
|
39
|
+
"@types/handlebars": "^4.1.0",
|
|
39
40
|
"@types/inquirer": "^9.0.7",
|
|
40
41
|
"@types/json2md": "^1.5.4",
|
|
41
42
|
"@types/node": "^18.18.6",
|
|
42
43
|
"@types/statuses": "^2.0.5",
|
|
43
44
|
"@types/update-notifier": "6.0.5",
|
|
45
|
+
"@vitest/coverage-v8": "^3.2.4",
|
|
44
46
|
"json2md": "^2.0.1",
|
|
45
47
|
"knip": "^5.43.6",
|
|
46
48
|
"npm-check-updates": "^16.14.6",
|
|
47
49
|
"tsup": "^8.4.0",
|
|
48
|
-
"typescript": "^5.2.2"
|
|
50
|
+
"typescript": "^5.2.2",
|
|
51
|
+
"vitest": "^3.2.4"
|
|
49
52
|
},
|
|
50
53
|
"files": [
|
|
51
54
|
"dist",
|
|
@@ -58,6 +61,7 @@
|
|
|
58
61
|
},
|
|
59
62
|
"dependencies": {
|
|
60
63
|
"@iarna/toml": "^2.2.5",
|
|
64
|
+
"@inquirer/prompts": "^5.5.0",
|
|
61
65
|
"async-listen": "^3.0.1",
|
|
62
66
|
"boxen": "^7.1.1",
|
|
63
67
|
"chalk": "^5.3.0",
|
|
@@ -65,7 +69,9 @@
|
|
|
65
69
|
"command-exists": "^1.2.9",
|
|
66
70
|
"commander": "^11.1.0",
|
|
67
71
|
"console-table-printer": "^2.11.2",
|
|
72
|
+
"dockerfile-ast": "^0.6.1",
|
|
68
73
|
"e2b": "^2.0.3",
|
|
74
|
+
"handlebars": "^4.7.8",
|
|
69
75
|
"inquirer": "^9.2.12",
|
|
70
76
|
"open": "^9.1.0",
|
|
71
77
|
"statuses": "^2.0.1",
|
|
@@ -81,8 +87,10 @@
|
|
|
81
87
|
"dev": "tsup --watch",
|
|
82
88
|
"lint": "eslint src",
|
|
83
89
|
"format": "prettier --write src",
|
|
84
|
-
"test": "pnpm build && cd testground/demo-basic && ../../dist/index.js template build",
|
|
85
90
|
"test:interactive": "pnpm build && ./dist/index.js",
|
|
91
|
+
"test": "vitest run",
|
|
92
|
+
"test:watch": "vitest watch",
|
|
93
|
+
"test:coverage": "vitest run --coverage",
|
|
86
94
|
"check-deps": "knip",
|
|
87
95
|
"update-deps": "ncu -u && pnpm i",
|
|
88
96
|
"generate-ref": "./scripts/generate_sdk_ref.sh"
|