opencode-supertask 0.1.6 → 0.1.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.
- package/dist/cli/index.js +43 -28
- package/dist/cli/index.js.map +1 -1
- package/dist/plugin/supertask.js +41 -15
- package/dist/plugin/supertask.js.map +1 -1
- package/package.json +1 -1
package/dist/plugin/supertask.js
CHANGED
|
@@ -9102,8 +9102,8 @@ var require_CronFileParser = __commonJS({
|
|
|
9102
9102
|
* @throws If file cannot be read
|
|
9103
9103
|
*/
|
|
9104
9104
|
static parseFileSync(filePath) {
|
|
9105
|
-
const { readFileSync } = __require("fs");
|
|
9106
|
-
const data =
|
|
9105
|
+
const { readFileSync: readFileSync2 } = __require("fs");
|
|
9106
|
+
const data = readFileSync2(filePath, "utf8");
|
|
9107
9107
|
return _CronFileParser.#parseContent(data);
|
|
9108
9108
|
}
|
|
9109
9109
|
/**
|
|
@@ -27233,9 +27233,19 @@ function parseDuration(input) {
|
|
|
27233
27233
|
import { execSync, spawnSync } from "child_process";
|
|
27234
27234
|
import { join as join2, dirname as dirname2 } from "path";
|
|
27235
27235
|
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
27236
|
+
import { readFileSync } from "fs";
|
|
27236
27237
|
var __dirname = dirname2(fileURLToPath2(import.meta.url));
|
|
27237
27238
|
var GATEWAY_ENTRY = join2(__dirname, "../gateway/index.js");
|
|
27238
27239
|
var PROCESS_NAME = "supertask-gateway";
|
|
27240
|
+
function getPackageVersion() {
|
|
27241
|
+
try {
|
|
27242
|
+
const pkgPath = join2(__dirname, "../package.json");
|
|
27243
|
+
const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
|
|
27244
|
+
return pkg.version || "0.0.0";
|
|
27245
|
+
} catch {
|
|
27246
|
+
return "0.0.0";
|
|
27247
|
+
}
|
|
27248
|
+
}
|
|
27239
27249
|
function pm2Bin() {
|
|
27240
27250
|
return process.platform === "win32" ? "pm2.cmd" : "pm2";
|
|
27241
27251
|
}
|
|
@@ -27279,11 +27289,38 @@ function findBunPath() {
|
|
|
27279
27289
|
return process.execPath;
|
|
27280
27290
|
}
|
|
27281
27291
|
}
|
|
27292
|
+
function pm2StartGateway(version3) {
|
|
27293
|
+
const bunPath = findBunPath();
|
|
27294
|
+
return pm2Exec([
|
|
27295
|
+
"start",
|
|
27296
|
+
bunPath,
|
|
27297
|
+
"--name",
|
|
27298
|
+
PROCESS_NAME,
|
|
27299
|
+
"--interpreter",
|
|
27300
|
+
"none",
|
|
27301
|
+
"--restart-delay",
|
|
27302
|
+
"5000",
|
|
27303
|
+
"--max-restarts",
|
|
27304
|
+
"30",
|
|
27305
|
+
"--",
|
|
27306
|
+
GATEWAY_ENTRY
|
|
27307
|
+
]);
|
|
27308
|
+
}
|
|
27282
27309
|
function ensureGateway() {
|
|
27310
|
+
const currentVersion = getPackageVersion();
|
|
27283
27311
|
try {
|
|
27284
27312
|
const list = pm2JsonList();
|
|
27285
27313
|
const proc = list.find((p) => p.name === PROCESS_NAME);
|
|
27286
27314
|
if (proc && proc.pm2_env?.status === "online") {
|
|
27315
|
+
const runningVersion = proc.pm2_env.pm_exec_path ? void 0 : void 0;
|
|
27316
|
+
const envVersion = proc.pm2_env.env?.SUPERTASK_VERSION;
|
|
27317
|
+
if (envVersion === currentVersion) {
|
|
27318
|
+
return;
|
|
27319
|
+
}
|
|
27320
|
+
console.log(`[supertask] Version changed: ${envVersion ?? "unknown"} \u2192 ${currentVersion}, reloading Gateway...`);
|
|
27321
|
+
pm2Exec(["delete", PROCESS_NAME]);
|
|
27322
|
+
pm2StartGateway(currentVersion);
|
|
27323
|
+
pm2Exec(["save"]);
|
|
27287
27324
|
return;
|
|
27288
27325
|
}
|
|
27289
27326
|
} catch {
|
|
@@ -27306,19 +27343,8 @@ function ensureGateway() {
|
|
|
27306
27343
|
if (existing) {
|
|
27307
27344
|
pm2Exec(["restart", PROCESS_NAME]);
|
|
27308
27345
|
} else {
|
|
27309
|
-
const
|
|
27310
|
-
|
|
27311
|
-
"start",
|
|
27312
|
-
GATEWAY_ENTRY,
|
|
27313
|
-
"--name",
|
|
27314
|
-
PROCESS_NAME,
|
|
27315
|
-
"--interpreter",
|
|
27316
|
-
bunPath,
|
|
27317
|
-
"--restart-delay",
|
|
27318
|
-
"5000",
|
|
27319
|
-
"--max-restarts",
|
|
27320
|
-
"30"
|
|
27321
|
-
]);
|
|
27346
|
+
const version3 = getPackageVersion();
|
|
27347
|
+
pm2StartGateway(version3);
|
|
27322
27348
|
}
|
|
27323
27349
|
pm2Exec(["save"]);
|
|
27324
27350
|
}
|