opencode-supertask 0.1.6 → 0.1.7
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 +47 -4
- package/dist/cli/index.js.map +1 -1
- package/dist/plugin/supertask.js +43 -3
- 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
|
}
|
|
@@ -27280,10 +27290,37 @@ function findBunPath() {
|
|
|
27280
27290
|
}
|
|
27281
27291
|
}
|
|
27282
27292
|
function ensureGateway() {
|
|
27293
|
+
const currentVersion = getPackageVersion();
|
|
27283
27294
|
try {
|
|
27284
27295
|
const list = pm2JsonList();
|
|
27285
27296
|
const proc = list.find((p) => p.name === PROCESS_NAME);
|
|
27286
27297
|
if (proc && proc.pm2_env?.status === "online") {
|
|
27298
|
+
const runningVersion = proc.pm2_env.pm_exec_path ? void 0 : void 0;
|
|
27299
|
+
const envVersion = proc.pm2_env.env?.SUPERTASK_VERSION;
|
|
27300
|
+
if (envVersion === currentVersion) {
|
|
27301
|
+
return;
|
|
27302
|
+
}
|
|
27303
|
+
console.log(`[supertask] Version changed: ${envVersion ?? "unknown"} \u2192 ${currentVersion}, reloading Gateway...`);
|
|
27304
|
+
const bunPath = findBunPath();
|
|
27305
|
+
pm2Exec([
|
|
27306
|
+
"delete",
|
|
27307
|
+
PROCESS_NAME
|
|
27308
|
+
]);
|
|
27309
|
+
pm2Exec([
|
|
27310
|
+
"start",
|
|
27311
|
+
GATEWAY_ENTRY,
|
|
27312
|
+
"--name",
|
|
27313
|
+
PROCESS_NAME,
|
|
27314
|
+
"--interpreter",
|
|
27315
|
+
bunPath,
|
|
27316
|
+
"--restart-delay",
|
|
27317
|
+
"5000",
|
|
27318
|
+
"--max-restarts",
|
|
27319
|
+
"30",
|
|
27320
|
+
"--env",
|
|
27321
|
+
`SUPERTASK_VERSION=${currentVersion}`
|
|
27322
|
+
]);
|
|
27323
|
+
pm2Exec(["save"]);
|
|
27287
27324
|
return;
|
|
27288
27325
|
}
|
|
27289
27326
|
} catch {
|
|
@@ -27307,6 +27344,7 @@ function ensureGateway() {
|
|
|
27307
27344
|
pm2Exec(["restart", PROCESS_NAME]);
|
|
27308
27345
|
} else {
|
|
27309
27346
|
const bunPath = findBunPath();
|
|
27347
|
+
const version3 = getPackageVersion();
|
|
27310
27348
|
pm2Exec([
|
|
27311
27349
|
"start",
|
|
27312
27350
|
GATEWAY_ENTRY,
|
|
@@ -27317,7 +27355,9 @@ function ensureGateway() {
|
|
|
27317
27355
|
"--restart-delay",
|
|
27318
27356
|
"5000",
|
|
27319
27357
|
"--max-restarts",
|
|
27320
|
-
"30"
|
|
27358
|
+
"30",
|
|
27359
|
+
"--env",
|
|
27360
|
+
`SUPERTASK_VERSION=${version3}`
|
|
27321
27361
|
]);
|
|
27322
27362
|
}
|
|
27323
27363
|
pm2Exec(["save"]);
|