@agent8/deploy 1.0.8 → 1.0.9

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 +11 -42
  2. package/package.json +1 -1
package/bin/agent8.js CHANGED
@@ -11,21 +11,8 @@ 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
22
14
  if (!fs.existsSync(envFilePath)) {
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));
15
+ fs.writeFileSync(envFilePath, "");
29
16
  }
30
17
 
31
18
  // Load previously deployed file hashes
@@ -39,42 +26,23 @@ if (fs.existsSync(deployedFilePath)) {
39
26
  }
40
27
  }
41
28
 
29
+ const envConfig = dotenv.parse(fs.readFileSync(envFilePath));
30
+
42
31
  const endpoint =
43
32
  envConfig.VITE_AGENT8_REMOTE_URL ||
44
33
  "https://verse8-simple-game-backend-609824224664.asia-northeast3.run.app";
45
34
 
46
- // If account/verse don't exist in .env, add them
47
35
  let verse = envConfig.VITE_AGENT8_VERSE;
48
- let account = envConfig.VITE_AGENT8_ACCOUNT;
49
- let envChanged = false;
36
+ let account = envConfig.VITE_AGENT8_ACCOUNT || "0xtest";
37
+ let signature = envConfig.VITE_AGENT8_SIGNATURE;
50
38
 
51
39
  if (!verse) {
52
- verse = generateRandomId();
53
- envConfig.VITE_AGENT8_VERSE = verse;
54
- envChanged = true;
55
- console.log("Generated new verse ID:", verse);
40
+ verse = crypto.randomBytes(16).toString("hex"); // Generate a random 32-byte string
41
+ fs.appendFileSync(envFilePath, `VITE_AGENT8_VERSE=${verse}\n`);
42
+ console.log("Generated random verse and updated .env:", verse);
56
43
  }
57
44
 
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
-
76
45
  console.log("Starting deployment to verse:", verse);
77
- console.log("Account:", account);
78
46
 
79
47
  // Files to upload
80
48
  const filesToUpload = [];
@@ -162,13 +130,14 @@ const uploadPromises = filesToUpload.map((fileInfo) => {
162
130
  form.append("path", uploadPath || "/");
163
131
 
164
132
  return axios
165
- .post(`${endpoint}/verses/${account}-${verse}/files`, form, {
133
+ .post(`${endpoint}/verses/${verse}/files`, form, {
166
134
  headers: {
167
135
  ...form.getHeaders(),
168
- "X-Access-Token": accessToken,
136
+ "X-Signature": signature,
169
137
  },
170
138
  })
171
139
  .then(() => {
140
+ // 경로 출력 처리
172
141
  console.log(`Uploaded: ${uploadPath}/${fileName}`);
173
142
  return true;
174
143
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent8/deploy",
3
- "version": "1.0.8",
3
+ "version": "1.0.9",
4
4
  "description": "A CLI tool for running agent8 commands",
5
5
  "main": "index.js",
6
6
  "bin": {