@agent8/deploy 1.0.7 → 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 -51
  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,51 +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);
56
- }
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;
75
-
76
- // Check if access token exists
77
- if (!accessToken) {
78
- console.error("Error: Missing V8_ACCESS_TOKEN environment variable");
79
- console.error(
80
- "Please set V8_ACCESS_TOKEN in your environment before deploying"
81
- );
82
- process.exit(1);
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);
83
43
  }
84
44
 
85
45
  console.log("Starting deployment to verse:", verse);
86
- console.log("Account:", account);
87
46
 
88
47
  // Files to upload
89
48
  const filesToUpload = [];
@@ -171,13 +130,14 @@ const uploadPromises = filesToUpload.map((fileInfo) => {
171
130
  form.append("path", uploadPath || "/");
172
131
 
173
132
  return axios
174
- .post(`${endpoint}/verses/${account}-${verse}/files`, form, {
133
+ .post(`${endpoint}/verses/${verse}/files`, form, {
175
134
  headers: {
176
135
  ...form.getHeaders(),
177
- "X-Access-Token": accessToken,
136
+ "X-Signature": signature,
178
137
  },
179
138
  })
180
139
  .then(() => {
140
+ // 경로 출력 처리
181
141
  console.log(`Uploaded: ${uploadPath}/${fileName}`);
182
142
  return true;
183
143
  })
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent8/deploy",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "A CLI tool for running agent8 commands",
5
5
  "main": "index.js",
6
6
  "bin": {