Skip to content

Commit 8127b49

Browse files
Merge pull request #94 from codesandbox/new-release
feat: New release
2 parents eda1e8e + 069b7c5 commit 8127b49

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

94 files changed

+5108
-3572
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
dist
55
tests
66
test.ts
7+
test-template
78

89
### macOS ###
910
*.DS_Store

TODO.md

Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
## QUESTIONS
2+
3+
- Should Snapshot Tags work like NPM?
4+
5+
- Create Sandbox with no wakeup config
6+
- Write files
7+
- Wait for condition
8+
- Hibernate
9+
- New endpoint to tag it
10+
- Sandbox is tagged (Check if hibernated?)
11+
- BIG QUESTION: Should we force prevent starting the Sandbox? What about TanStack
12+
13+
- New endpoint to create an alias to any tag
14+
15+
- Change endpoint for Sandbox creation to allow tags/aliases as id
16+
17+
- What is Tag / Alias format?
18+
19+
## USER QUESTIONS
20+
21+
## TODO
22+
23+
- Highlight snapshot building in docs
24+
- https://github.com/codesandbox/codesandbox-applications/pull/4645
25+
- Publish browser-static-server
26+
27+
# 1 New API
28+
29+
```ts
30+
const sdk = new CodeSandbox(apiToken);
31+
32+
const sandbox = await sdk.sandbox.resume(id);
33+
const sandbox = await sdk.sandbox.create(SandboxOptions & StartOptions);
34+
35+
sandbox.isUpToDate;
36+
sandbox.bootupType;
37+
sandbox.cluster;
38+
sandbox.connect();
39+
sandbox.createBrowserSession();
40+
sandbox.createRestClient();
41+
sandbox.updateTier();
42+
sandbox.updateHibernationTimeout();
43+
44+
sdk.sandbox.shutdown(id);
45+
sdk.sandbox.previewTokens.create(id);
46+
47+
const session = await sandbox.createBrowserSession();
48+
const client = sandbox.connect();
49+
const client = sandbox.createRestClient();
50+
```
51+
52+
# 2 Git clone support
53+
54+
```ts
55+
// Factory.ai
56+
// Create base template
57+
// const sbx = await sdk.sandbox.create();
58+
// sbx.git.clone();
59+
// -> /project/sandbox
60+
// git set-remote origin ...
61+
// git pull
62+
63+
// /project/sandbox/.git -> /persisted/.git
64+
65+
/**
66+
* sdk.sandbox.create({ source: {
67+
* type: 'git',
68+
* url: 'https://github.com/sandbox-git/sandbox-git.git',
69+
* branch: 'main',
70+
* gitAccessToken: '...'
71+
* } })
72+
* 1. create sandbox
73+
* 2. ...
74+
* 3. clone
75+
*
76+
* // Source = Dropbox
77+
* // Source = Zip
78+
*
79+
*
80+
* // API create zip
81+
*
82+
* sandbox.create({
83+
* source: {
84+
* type: 'zip',
85+
* url: 'https://example.com/my-zip-file.zip'
86+
* }
87+
* });
88+
*/
89+
90+
await sandbox.git.clone({
91+
url: "https://github.com/sandbox-git/sandbox-git.git",
92+
branch: "main",
93+
});
94+
95+
// rm -rf /project/sandbox/*
96+
//
97+
98+
await sandbox.git.pull();
99+
await sandbox.git.checkout("main");
100+
101+
//
102+
```
103+
104+
# 3 Snapshot Tagging
105+
106+
```ts
107+
sdk.sandbox.create({
108+
files: {},
109+
});
110+
```
111+
112+
# Export types properly

esbuild.cjs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ Promise.all([
2727
// .cjs extension is required because "type": "module" is set in package.json
2828
outfile: "dist/cjs/browser.cjs",
2929
platform: "browser",
30+
// pitcher-common currently requires this, but breaks the first experience
31+
banner: {
32+
js: `if (typeof window !== "undefined" && !window.process) {
33+
window.process = {
34+
env: {},
35+
};
36+
}
37+
`,
38+
},
3039
plugins: [browserifyPlugin],
3140
}),
3241

@@ -37,6 +46,15 @@ Promise.all([
3746
format: "esm",
3847
outdir: "dist/esm",
3948
platform: "browser",
49+
// pitcher-common currently requires this, but breaks the first experience
50+
banner: {
51+
js: `if (typeof window !== "undefined" && !window.process) {
52+
window.process = {
53+
env: {},
54+
};
55+
}
56+
`,
57+
},
4058
plugins: [browserifyPlugin],
4159
}),
4260

0 commit comments

Comments
 (0)