@colyseus/tools 0.15.31 → 0.15.33

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/package.json +1 -1
  2. package/post-deploy.js +28 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@colyseus/tools",
3
- "version": "0.15.31",
3
+ "version": "0.15.33",
4
4
  "description": "Colyseus Tools for Production",
5
5
  "input": "./src/index.ts",
6
6
  "main": "./build/index.js",
package/post-deploy.js CHANGED
@@ -62,16 +62,21 @@ function updateColyseusBootService() {
62
62
  const COLYSEUS_CLOUD_BOOT_SERVICE = '/etc/systemd/system/colyseus-boot.service';
63
63
 
64
64
  // ignore if no boot service found
65
- if (!fs.existsSync(COLYSEUS_CLOUD_BOOT_SERVICE)) { return; }
65
+ if (!fs.existsSync(COLYSEUS_CLOUD_BOOT_SERVICE)) {
66
+ return;
67
+ }
66
68
 
67
69
  const workingDirectory = pm2.cwd;
68
- const execStart = __filename;
70
+ const execStart = `${detectPackageManager()} run colyseus-post-deploy`;
69
71
 
70
72
  const contents = fs.readFileSync(COLYSEUS_CLOUD_BOOT_SERVICE, 'utf8');
71
-
72
- fs.writeFileSync(COLYSEUS_CLOUD_BOOT_SERVICE, contents
73
- .replace(/WorkingDirectory=(.*)/, `WorkingDirectory=${workingDirectory}`)
74
- .replace(/ExecStart=(.*)/, `ExecStart=${execStart}`));
73
+ try {
74
+ fs.writeFileSync(COLYSEUS_CLOUD_BOOT_SERVICE, contents
75
+ .replace(/WorkingDirectory=(.*)/, `WorkingDirectory=${workingDirectory}`)
76
+ .replace(/ExecStart=(.*)/, `ExecStart=${execStart}`));
77
+ } catch (e) {
78
+ // couldn't write to file
79
+ }
75
80
  }
76
81
 
77
82
  function updateAndReloadNginx() {
@@ -116,6 +121,23 @@ function updateAndReloadNginx() {
116
121
  });
117
122
  }
118
123
 
124
+ function detectPackageManager() {
125
+ const lockfiles = {
126
+ npm: path.resolve(pm2.cwd, 'package-lock.json'),
127
+ yarn: path.resolve(pm2.cwd, 'yarn.lock'),
128
+ pnpm: path.resolve(pm2.cwd, 'pnpm-lock.yaml'),
129
+ bun: path.resolve(pm2.cwd, 'bun.lockb'),
130
+ };
131
+
132
+ for (const [key, value] of Object.entries(lockfiles)) {
133
+ if (fs.existsSync(value)) {
134
+ return key;
135
+ }
136
+ }
137
+
138
+ return "npm";
139
+ }
140
+
119
141
  function bailOnErr(err) {
120
142
  if (err) {
121
143
  console.error(err);