@agent8/deploy 1.0.6 → 1.0.8

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.
Files changed (2) hide show
  1. package/bin/agent8.js +42 -17
  2. package/package.json +1 -1
package/bin/agent8.js CHANGED
@@ -11,9 +11,21 @@ const [, , command, fnName, argsString] = process.argv;
11
11
  const envFilePath = path.resolve(process.cwd(), ".env");
12
12
  const deployedFilePath = path.resolve(process.cwd(), ".deployed");
13
13
 
14
+ // Generate random ID for account/verse if needed
15
+ const generateRandomId = () => {
16
+ return crypto.randomBytes(8).toString("hex");
17
+ };
18
+
19
+ let envConfig = {};
20
+
21
+ // Check if .env exists, create if not
14
22
  if (!fs.existsSync(envFilePath)) {
15
- console.error("Error: .env file does not exist");
16
- process.exit(1);
23
+ console.log("Creating new .env file with generated values");
24
+ const defaultEnv = `VITE_AGENT8_ACCOUNT=${generateRandomId()}\nVITE_AGENT8_VERSE=${generateRandomId()}\n`;
25
+ fs.writeFileSync(envFilePath, defaultEnv);
26
+ envConfig = dotenv.parse(fs.readFileSync(envFilePath));
27
+ } else {
28
+ envConfig = dotenv.parse(fs.readFileSync(envFilePath));
17
29
  }
18
30
 
19
31
  // Load previously deployed file hashes
@@ -27,26 +39,40 @@ if (fs.existsSync(deployedFilePath)) {
27
39
  }
28
40
  }
29
41
 
30
- const envConfig = dotenv.parse(fs.readFileSync(envFilePath));
31
-
32
42
  const endpoint =
33
43
  envConfig.VITE_AGENT8_REMOTE_URL ||
34
44
  "https://verse8-simple-game-backend-609824224664.asia-northeast3.run.app";
35
45
 
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);
46
+ // If account/verse don't exist in .env, add them
47
+ let verse = envConfig.VITE_AGENT8_VERSE;
48
+ let account = envConfig.VITE_AGENT8_ACCOUNT;
49
+ let envChanged = false;
50
+
51
+ if (!verse) {
52
+ verse = generateRandomId();
53
+ envConfig.VITE_AGENT8_VERSE = verse;
54
+ envChanged = true;
55
+ console.log("Generated new verse ID:", verse);
48
56
  }
49
57
 
58
+ if (!account) {
59
+ account = generateRandomId();
60
+ envConfig.VITE_AGENT8_ACCOUNT = account;
61
+ envChanged = true;
62
+ console.log("Generated new account ID:", account);
63
+ }
64
+
65
+ // Save updated .env if needed
66
+ if (envChanged) {
67
+ const envContent = Object.entries(envConfig)
68
+ .map(([key, value]) => `${key}=${value}`)
69
+ .join("\n");
70
+ fs.writeFileSync(envFilePath, envContent);
71
+ console.log("Updated .env file with new values");
72
+ }
73
+
74
+ const accessToken = process.env.V8_ACCESS_TOKEN || "TESTER";
75
+
50
76
  console.log("Starting deployment to verse:", verse);
51
77
  console.log("Account:", account);
52
78
 
@@ -143,7 +169,6 @@ const uploadPromises = filesToUpload.map((fileInfo) => {
143
169
  },
144
170
  })
145
171
  .then(() => {
146
- // 경로 출력 처리
147
172
  console.log(`Uploaded: ${uploadPath}/${fileName}`);
148
173
  return true;
149
174
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent8/deploy",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "description": "A CLI tool for running agent8 commands",
5
5
  "main": "index.js",
6
6
  "bin": {