@agent8/deploy 1.0.2 → 1.0.4

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 +20 -9
  2. package/package.json +1 -1
package/bin/agent8.js CHANGED
@@ -57,15 +57,26 @@ const calculateFileHash = (filePath) => {
57
57
  // Check for server.js
58
58
  const serverFilePath = path.resolve(process.cwd(), "server.js");
59
59
  if (fs.existsSync(serverFilePath)) {
60
- const hash = calculateFileHash(serverFilePath);
61
- newHashes["server.js"] = hash;
62
-
63
- if (hash !== deployedHashes["server.js"]) {
64
- filesToUpload.push({
65
- filePath: serverFilePath,
66
- uploadPath: "",
67
- fileName: "server.js",
68
- });
60
+ // Validate server.js syntax before deployment
61
+ try {
62
+ const serverContent = fs.readFileSync(serverFilePath, "utf8");
63
+ eval(
64
+ `(function() { const $global = {}; const $room = {}; const $sender = {}; ${serverContent}; new Server(); })`
65
+ )();
66
+
67
+ const hash = calculateFileHash(serverFilePath);
68
+ newHashes["server.js"] = hash;
69
+
70
+ if (hash !== deployedHashes["server.js"]) {
71
+ filesToUpload.push({
72
+ filePath: serverFilePath,
73
+ uploadPath: "",
74
+ fileName: "server.js",
75
+ });
76
+ }
77
+ } catch (error) {
78
+ console.error("Error in server.js syntax:", error.message);
79
+ process.exit(1);
69
80
  }
70
81
  }
71
82
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agent8/deploy",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "description": "A CLI tool for running agent8 commands",
5
5
  "main": "index.js",
6
6
  "bin": {