@agent8/deploy 1.0.4 → 1.0.6
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/bin/agent8.js +18 -14
- package/package.json +1 -1
package/bin/agent8.js
CHANGED
|
@@ -12,7 +12,8 @@ const envFilePath = path.resolve(process.cwd(), ".env");
|
|
|
12
12
|
const deployedFilePath = path.resolve(process.cwd(), ".deployed");
|
|
13
13
|
|
|
14
14
|
if (!fs.existsSync(envFilePath)) {
|
|
15
|
-
|
|
15
|
+
console.error("Error: .env file does not exist");
|
|
16
|
+
process.exit(1);
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
// Load previously deployed file hashes
|
|
@@ -32,17 +33,22 @@ const endpoint =
|
|
|
32
33
|
envConfig.VITE_AGENT8_REMOTE_URL ||
|
|
33
34
|
"https://verse8-simple-game-backend-609824224664.asia-northeast3.run.app";
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
if
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
console.
|
|
36
|
+
const verse = envConfig.VITE_AGENT8_VERSE;
|
|
37
|
+
const account = envConfig.VITE_AGENT8_ACCOUNT;
|
|
38
|
+
const accessToken = process.env.V8_ACCESS_TOKEN;
|
|
39
|
+
|
|
40
|
+
// Check if required variables exist
|
|
41
|
+
if (!verse || !account || !accessToken) {
|
|
42
|
+
console.error("Error: Missing required deployment variables");
|
|
43
|
+
console.error("VITE_AGENT8_VERSE:", verse ? "✓" : "✗");
|
|
44
|
+
console.error("VITE_AGENT8_ACCOUNT:", account ? "✓" : "✗");
|
|
45
|
+
console.error("V8_ACCESS_TOKEN:", accessToken ? "✓" : "✗");
|
|
46
|
+
console.error("Please set all required variables before deploying");
|
|
47
|
+
process.exit(1);
|
|
43
48
|
}
|
|
44
49
|
|
|
45
50
|
console.log("Starting deployment to verse:", verse);
|
|
51
|
+
console.log("Account:", account);
|
|
46
52
|
|
|
47
53
|
// Files to upload
|
|
48
54
|
const filesToUpload = [];
|
|
@@ -60,9 +66,7 @@ if (fs.existsSync(serverFilePath)) {
|
|
|
60
66
|
// Validate server.js syntax before deployment
|
|
61
67
|
try {
|
|
62
68
|
const serverContent = fs.readFileSync(serverFilePath, "utf8");
|
|
63
|
-
eval(
|
|
64
|
-
`(function() { const $global = {}; const $room = {}; const $sender = {}; ${serverContent}; new Server(); })`
|
|
65
|
-
)();
|
|
69
|
+
eval(`(function() { ${serverContent}; })`)();
|
|
66
70
|
|
|
67
71
|
const hash = calculateFileHash(serverFilePath);
|
|
68
72
|
newHashes["server.js"] = hash;
|
|
@@ -132,10 +136,10 @@ const uploadPromises = filesToUpload.map((fileInfo) => {
|
|
|
132
136
|
form.append("path", uploadPath || "/");
|
|
133
137
|
|
|
134
138
|
return axios
|
|
135
|
-
.post(`${endpoint}/verses/${verse}/files`, form, {
|
|
139
|
+
.post(`${endpoint}/verses/${account}-${verse}/files`, form, {
|
|
136
140
|
headers: {
|
|
137
141
|
...form.getHeaders(),
|
|
138
|
-
"X-
|
|
142
|
+
"X-Access-Token": accessToken,
|
|
139
143
|
},
|
|
140
144
|
})
|
|
141
145
|
.then(() => {
|