freestyle-sandboxes 0.0.22 → 0.0.24
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.cjs +1 -3
- package/dist/index.mjs +1 -3
- package/package.json +2 -1
- package/src/index.ts +1 -3
- package/src/utils/index.ts +85 -0
package/dist/index.cjs
CHANGED
|
@@ -237,9 +237,7 @@ Message: ${response.error?.message}`
|
|
|
237
237
|
if (response.data) {
|
|
238
238
|
return response.data;
|
|
239
239
|
} else {
|
|
240
|
-
throw new Error(
|
|
241
|
-
`Failed to create domain verification request for domain ${domain}: ${response.error.message}`
|
|
242
|
-
);
|
|
240
|
+
throw new Error(response.error.message);
|
|
243
241
|
}
|
|
244
242
|
}
|
|
245
243
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -235,9 +235,7 @@ Message: ${response.error?.message}`
|
|
|
235
235
|
if (response.data) {
|
|
236
236
|
return response.data;
|
|
237
237
|
} else {
|
|
238
|
-
throw new Error(
|
|
239
|
-
`Failed to create domain verification request for domain ${domain}: ${response.error.message}`
|
|
240
|
-
);
|
|
238
|
+
throw new Error(response.error.message);
|
|
241
239
|
}
|
|
242
240
|
}
|
|
243
241
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "freestyle-sandboxes",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.24",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -65,6 +65,7 @@
|
|
|
65
65
|
"@langchain/langgraph": "^0.2.44",
|
|
66
66
|
"@mastra/core": "^0.1.27-alpha.66",
|
|
67
67
|
"ai": "^4.0.25",
|
|
68
|
+
"glob": "^11.0.1",
|
|
68
69
|
"humanlayer": "^0.7.0",
|
|
69
70
|
"openai": "^4.77.3",
|
|
70
71
|
"openapi": "^1.0.1",
|
package/src/index.ts
CHANGED
|
@@ -160,9 +160,7 @@ export class FreestyleSandboxes {
|
|
|
160
160
|
if (response.data) {
|
|
161
161
|
return response.data;
|
|
162
162
|
} else {
|
|
163
|
-
throw new Error(
|
|
164
|
-
`Failed to create domain verification request for domain ${domain}: ${response.error.message}`
|
|
165
|
-
);
|
|
163
|
+
throw new Error(response.error.message);
|
|
166
164
|
}
|
|
167
165
|
}
|
|
168
166
|
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import * as sandbox_openapi from "../../openapi/index.ts";
|
|
2
|
+
import { glob, globSync } from "glob";
|
|
3
|
+
import * as fs from "fs/promises";
|
|
4
|
+
import * as fsSync from "fs";
|
|
5
|
+
import * as path from "path";
|
|
6
|
+
|
|
7
|
+
export const prepareDirForDeployment = async (
|
|
8
|
+
directory: string
|
|
9
|
+
): Promise<sandbox_openapi.FreestyleDeployWebPayload["files"]> => {
|
|
10
|
+
const files: sandbox_openapi.FreestyleDeployWebPayload["files"] = {};
|
|
11
|
+
|
|
12
|
+
const patterns = await glob("**/*", {
|
|
13
|
+
cwd: directory,
|
|
14
|
+
nodir: true,
|
|
15
|
+
ignore: ["**/node_modules/**"],
|
|
16
|
+
absolute: false,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
for (const relativePath of patterns) {
|
|
20
|
+
try {
|
|
21
|
+
const filePath = path.join(directory, relativePath);
|
|
22
|
+
const content = await fs.readFile(filePath, "base64");
|
|
23
|
+
files[relativePath] = {
|
|
24
|
+
content,
|
|
25
|
+
encoding: "base64",
|
|
26
|
+
};
|
|
27
|
+
} catch (error) {
|
|
28
|
+
console.error(`Error reading file ${relativePath}:`, error);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return files;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export const prepareDirForDeploymentSync = (directory: string) => {
|
|
36
|
+
const files: sandbox_openapi.FreestyleDeployWebPayload["files"] = {};
|
|
37
|
+
|
|
38
|
+
const patterns = globSync("**/*", {
|
|
39
|
+
cwd: directory,
|
|
40
|
+
nodir: true,
|
|
41
|
+
ignore: ["**/node_modules/**"],
|
|
42
|
+
absolute: false,
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
for (const relativePath of patterns) {
|
|
46
|
+
try {
|
|
47
|
+
const filePath = path.join(directory, relativePath);
|
|
48
|
+
const content = fsSync.readFileSync(filePath, "base64");
|
|
49
|
+
files[relativePath] = {
|
|
50
|
+
content,
|
|
51
|
+
encoding: "base64",
|
|
52
|
+
};
|
|
53
|
+
} catch (error) {
|
|
54
|
+
console.error(`Error reading file ${relativePath}:`, error);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return files;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* This is in beta, and may not work as expected. SUBJECT TO CHANGE.
|
|
63
|
+
*/
|
|
64
|
+
export const prepareNextJsForDeployment = async (
|
|
65
|
+
directory: string
|
|
66
|
+
): Promise<sandbox_openapi.FreestyleDeployWebPayload["files"]> => {
|
|
67
|
+
const publicDir = path.join(directory, "public");
|
|
68
|
+
const nextPublicDestination = path.join(directory, ".next/standalone/public");
|
|
69
|
+
|
|
70
|
+
const staticDir = path.join(directory, ".next/static");
|
|
71
|
+
const nextStaticDestination = path.join(
|
|
72
|
+
directory,
|
|
73
|
+
".next/standalone/.next/static"
|
|
74
|
+
);
|
|
75
|
+
|
|
76
|
+
// now copy everything from publicDir to nextPublicDestination
|
|
77
|
+
// and everything from staticDir to nextStaticDestination
|
|
78
|
+
await fs.mkdir(nextPublicDestination, { recursive: true });
|
|
79
|
+
await fs.copyFile(publicDir, nextPublicDestination);
|
|
80
|
+
|
|
81
|
+
await fs.mkdir(nextStaticDestination, { recursive: true });
|
|
82
|
+
await fs.copyFile(staticDir, nextStaticDestination);
|
|
83
|
+
|
|
84
|
+
return await prepareDirForDeployment(directory);
|
|
85
|
+
};
|