bgrun 3.12.23 → 3.12.24
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/api.js +28 -66
- package/dist/deploy.js +28 -66
- package/dist/deps.js +14 -1
- package/dist/index.js +89 -83
- package/package.json +1 -1
package/dist/api.js
CHANGED
|
@@ -825,7 +825,7 @@ var init_db = __esm(() => {
|
|
|
825
825
|
// src/utils.ts
|
|
826
826
|
import * as fs2 from "fs";
|
|
827
827
|
import * as os2 from "os";
|
|
828
|
-
import { join as join3 } from "path";
|
|
828
|
+
import { delimiter, dirname, join as join3 } from "path";
|
|
829
829
|
function parseEnvString(envString) {
|
|
830
830
|
const env = {};
|
|
831
831
|
envString.split(",").forEach((pair) => {
|
|
@@ -841,6 +841,17 @@ function calculateRuntime(startTime) {
|
|
|
841
841
|
const diffInMinutes = Math.floor((now - start) / (1000 * 60));
|
|
842
842
|
return `${diffInMinutes} minutes`;
|
|
843
843
|
}
|
|
844
|
+
function prependPathEntry(existingPath, entry) {
|
|
845
|
+
if (!existingPath)
|
|
846
|
+
return entry;
|
|
847
|
+
const parts = existingPath.split(delimiter).filter(Boolean);
|
|
848
|
+
const normalizedEntry = process.platform === "win32" ? entry.toLowerCase() : entry;
|
|
849
|
+
const deduped = parts.filter((part) => {
|
|
850
|
+
const normalizedPart = process.platform === "win32" ? part.toLowerCase() : part;
|
|
851
|
+
return normalizedPart !== normalizedEntry;
|
|
852
|
+
});
|
|
853
|
+
return [entry, ...deduped].join(delimiter);
|
|
854
|
+
}
|
|
844
855
|
function parseCommandEnv(command) {
|
|
845
856
|
const env = {};
|
|
846
857
|
const trimmed = command.trim();
|
|
@@ -882,6 +893,8 @@ function buildManagedProcessEnv(parentEnv, processEnv = {}) {
|
|
|
882
893
|
continue;
|
|
883
894
|
sanitizedParentEnv[key] = value;
|
|
884
895
|
}
|
|
896
|
+
const bunDir = dirname(process.execPath);
|
|
897
|
+
sanitizedParentEnv.PATH = prependPathEntry(sanitizedParentEnv.PATH, bunDir);
|
|
885
898
|
return { ...sanitizedParentEnv, ...processEnv };
|
|
886
899
|
}
|
|
887
900
|
function stringifyEnvString(env) {
|
|
@@ -1181,79 +1194,28 @@ import { join as join4 } from "path";
|
|
|
1181
1194
|
|
|
1182
1195
|
// src/cli-helpers.ts
|
|
1183
1196
|
init_db();
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
"
|
|
1187
|
-
"
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
"december"
|
|
1197
|
-
];
|
|
1198
|
-
var DAY_NAMES = [
|
|
1199
|
-
"",
|
|
1200
|
-
"first",
|
|
1201
|
-
"second",
|
|
1202
|
-
"third",
|
|
1203
|
-
"fourth",
|
|
1204
|
-
"fifth",
|
|
1205
|
-
"sixth",
|
|
1206
|
-
"seventh",
|
|
1207
|
-
"eighth",
|
|
1208
|
-
"ninth",
|
|
1209
|
-
"tenth",
|
|
1210
|
-
"eleventh",
|
|
1211
|
-
"twelfth",
|
|
1212
|
-
"thirteenth",
|
|
1213
|
-
"fourteenth",
|
|
1214
|
-
"fifteenth",
|
|
1215
|
-
"sixteenth",
|
|
1216
|
-
"seventeenth",
|
|
1217
|
-
"eighteenth",
|
|
1218
|
-
"nineteenth",
|
|
1219
|
-
"twentieth",
|
|
1220
|
-
"twenty-first",
|
|
1221
|
-
"twenty-second",
|
|
1222
|
-
"twenty-third",
|
|
1223
|
-
"twenty-fourth",
|
|
1224
|
-
"twenty-fifth",
|
|
1225
|
-
"twenty-sixth",
|
|
1226
|
-
"twenty-seventh",
|
|
1227
|
-
"twenty-eighth",
|
|
1228
|
-
"twenty-ninth",
|
|
1229
|
-
"thirtieth",
|
|
1230
|
-
"thirty-first"
|
|
1231
|
-
];
|
|
1232
|
-
function pad2(value) {
|
|
1233
|
-
return String(value).padStart(2, "0");
|
|
1234
|
-
}
|
|
1235
|
-
function buildDateProcessName(now = new Date) {
|
|
1236
|
-
const month = MONTH_NAMES[now.getMonth()] || "process";
|
|
1237
|
-
const day = DAY_NAMES[now.getDate()] || "day";
|
|
1238
|
-
return `${month}-${day}`;
|
|
1239
|
-
}
|
|
1240
|
-
function generateAutoProcessName(now = new Date) {
|
|
1241
|
-
const baseName = buildDateProcessName(now);
|
|
1197
|
+
import { basename, resolve } from "path";
|
|
1198
|
+
function sanitizeProcessName(value) {
|
|
1199
|
+
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/-+/g, "-").replace(/^[-._]+|[-._]+$/g, "");
|
|
1200
|
+
return normalized || "process";
|
|
1201
|
+
}
|
|
1202
|
+
function buildDirectoryProcessName(directory) {
|
|
1203
|
+
const resolved = resolve(directory);
|
|
1204
|
+
const folderName = basename(resolved);
|
|
1205
|
+
return sanitizeProcessName(folderName);
|
|
1206
|
+
}
|
|
1207
|
+
function generateAutoProcessName(directory) {
|
|
1208
|
+
const baseName = buildDirectoryProcessName(directory);
|
|
1242
1209
|
if (!getProcess(baseName)) {
|
|
1243
1210
|
return baseName;
|
|
1244
1211
|
}
|
|
1245
|
-
const timeSuffix = `${pad2(now.getHours())}${pad2(now.getMinutes())}${pad2(now.getSeconds())}`;
|
|
1246
|
-
const timeName = `${baseName}-${timeSuffix}`;
|
|
1247
|
-
if (!getProcess(timeName)) {
|
|
1248
|
-
return timeName;
|
|
1249
|
-
}
|
|
1250
1212
|
for (let i = 1;i < 1000; i++) {
|
|
1251
|
-
const candidate = `${
|
|
1213
|
+
const candidate = `${baseName}-${i}`;
|
|
1252
1214
|
if (!getProcess(candidate)) {
|
|
1253
1215
|
return candidate;
|
|
1254
1216
|
}
|
|
1255
1217
|
}
|
|
1256
|
-
return `${
|
|
1218
|
+
return `${baseName}-${Date.now()}`;
|
|
1257
1219
|
}
|
|
1258
1220
|
function shellQuoteArg(arg) {
|
|
1259
1221
|
if (process.platform === "win32") {
|
package/dist/deploy.js
CHANGED
|
@@ -825,7 +825,7 @@ var init_db = __esm(() => {
|
|
|
825
825
|
// src/utils.ts
|
|
826
826
|
import * as fs2 from "fs";
|
|
827
827
|
import * as os2 from "os";
|
|
828
|
-
import { join as join3 } from "path";
|
|
828
|
+
import { delimiter, dirname, join as join3 } from "path";
|
|
829
829
|
function parseEnvString(envString) {
|
|
830
830
|
const env = {};
|
|
831
831
|
envString.split(",").forEach((pair) => {
|
|
@@ -841,6 +841,17 @@ function calculateRuntime(startTime) {
|
|
|
841
841
|
const diffInMinutes = Math.floor((now - start) / (1000 * 60));
|
|
842
842
|
return `${diffInMinutes} minutes`;
|
|
843
843
|
}
|
|
844
|
+
function prependPathEntry(existingPath, entry) {
|
|
845
|
+
if (!existingPath)
|
|
846
|
+
return entry;
|
|
847
|
+
const parts = existingPath.split(delimiter).filter(Boolean);
|
|
848
|
+
const normalizedEntry = process.platform === "win32" ? entry.toLowerCase() : entry;
|
|
849
|
+
const deduped = parts.filter((part) => {
|
|
850
|
+
const normalizedPart = process.platform === "win32" ? part.toLowerCase() : part;
|
|
851
|
+
return normalizedPart !== normalizedEntry;
|
|
852
|
+
});
|
|
853
|
+
return [entry, ...deduped].join(delimiter);
|
|
854
|
+
}
|
|
844
855
|
function parseCommandEnv(command) {
|
|
845
856
|
const env = {};
|
|
846
857
|
const trimmed = command.trim();
|
|
@@ -882,6 +893,8 @@ function buildManagedProcessEnv(parentEnv, processEnv = {}) {
|
|
|
882
893
|
continue;
|
|
883
894
|
sanitizedParentEnv[key] = value;
|
|
884
895
|
}
|
|
896
|
+
const bunDir = dirname(process.execPath);
|
|
897
|
+
sanitizedParentEnv.PATH = prependPathEntry(sanitizedParentEnv.PATH, bunDir);
|
|
885
898
|
return { ...sanitizedParentEnv, ...processEnv };
|
|
886
899
|
}
|
|
887
900
|
function stringifyEnvString(env) {
|
|
@@ -1180,79 +1193,28 @@ import { join as join4 } from "path";
|
|
|
1180
1193
|
|
|
1181
1194
|
// src/cli-helpers.ts
|
|
1182
1195
|
init_db();
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
"
|
|
1186
|
-
"
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
"december"
|
|
1196
|
-
];
|
|
1197
|
-
var DAY_NAMES = [
|
|
1198
|
-
"",
|
|
1199
|
-
"first",
|
|
1200
|
-
"second",
|
|
1201
|
-
"third",
|
|
1202
|
-
"fourth",
|
|
1203
|
-
"fifth",
|
|
1204
|
-
"sixth",
|
|
1205
|
-
"seventh",
|
|
1206
|
-
"eighth",
|
|
1207
|
-
"ninth",
|
|
1208
|
-
"tenth",
|
|
1209
|
-
"eleventh",
|
|
1210
|
-
"twelfth",
|
|
1211
|
-
"thirteenth",
|
|
1212
|
-
"fourteenth",
|
|
1213
|
-
"fifteenth",
|
|
1214
|
-
"sixteenth",
|
|
1215
|
-
"seventeenth",
|
|
1216
|
-
"eighteenth",
|
|
1217
|
-
"nineteenth",
|
|
1218
|
-
"twentieth",
|
|
1219
|
-
"twenty-first",
|
|
1220
|
-
"twenty-second",
|
|
1221
|
-
"twenty-third",
|
|
1222
|
-
"twenty-fourth",
|
|
1223
|
-
"twenty-fifth",
|
|
1224
|
-
"twenty-sixth",
|
|
1225
|
-
"twenty-seventh",
|
|
1226
|
-
"twenty-eighth",
|
|
1227
|
-
"twenty-ninth",
|
|
1228
|
-
"thirtieth",
|
|
1229
|
-
"thirty-first"
|
|
1230
|
-
];
|
|
1231
|
-
function pad2(value) {
|
|
1232
|
-
return String(value).padStart(2, "0");
|
|
1233
|
-
}
|
|
1234
|
-
function buildDateProcessName(now = new Date) {
|
|
1235
|
-
const month = MONTH_NAMES[now.getMonth()] || "process";
|
|
1236
|
-
const day = DAY_NAMES[now.getDate()] || "day";
|
|
1237
|
-
return `${month}-${day}`;
|
|
1238
|
-
}
|
|
1239
|
-
function generateAutoProcessName(now = new Date) {
|
|
1240
|
-
const baseName = buildDateProcessName(now);
|
|
1196
|
+
import { basename, resolve } from "path";
|
|
1197
|
+
function sanitizeProcessName(value) {
|
|
1198
|
+
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/-+/g, "-").replace(/^[-._]+|[-._]+$/g, "");
|
|
1199
|
+
return normalized || "process";
|
|
1200
|
+
}
|
|
1201
|
+
function buildDirectoryProcessName(directory) {
|
|
1202
|
+
const resolved = resolve(directory);
|
|
1203
|
+
const folderName = basename(resolved);
|
|
1204
|
+
return sanitizeProcessName(folderName);
|
|
1205
|
+
}
|
|
1206
|
+
function generateAutoProcessName(directory) {
|
|
1207
|
+
const baseName = buildDirectoryProcessName(directory);
|
|
1241
1208
|
if (!getProcess(baseName)) {
|
|
1242
1209
|
return baseName;
|
|
1243
1210
|
}
|
|
1244
|
-
const timeSuffix = `${pad2(now.getHours())}${pad2(now.getMinutes())}${pad2(now.getSeconds())}`;
|
|
1245
|
-
const timeName = `${baseName}-${timeSuffix}`;
|
|
1246
|
-
if (!getProcess(timeName)) {
|
|
1247
|
-
return timeName;
|
|
1248
|
-
}
|
|
1249
1211
|
for (let i = 1;i < 1000; i++) {
|
|
1250
|
-
const candidate = `${
|
|
1212
|
+
const candidate = `${baseName}-${i}`;
|
|
1251
1213
|
if (!getProcess(candidate)) {
|
|
1252
1214
|
return candidate;
|
|
1253
1215
|
}
|
|
1254
1216
|
}
|
|
1255
|
-
return `${
|
|
1217
|
+
return `${baseName}-${Date.now()}`;
|
|
1256
1218
|
}
|
|
1257
1219
|
function shellQuoteArg(arg) {
|
|
1258
1220
|
if (process.platform === "win32") {
|
package/dist/deps.js
CHANGED
|
@@ -825,7 +825,7 @@ var init_db = __esm(() => {
|
|
|
825
825
|
// src/utils.ts
|
|
826
826
|
import * as fs2 from "fs";
|
|
827
827
|
import * as os2 from "os";
|
|
828
|
-
import { join as join3 } from "path";
|
|
828
|
+
import { delimiter, dirname, join as join3 } from "path";
|
|
829
829
|
function parseEnvString(envString) {
|
|
830
830
|
const env = {};
|
|
831
831
|
envString.split(",").forEach((pair) => {
|
|
@@ -841,6 +841,17 @@ function calculateRuntime(startTime) {
|
|
|
841
841
|
const diffInMinutes = Math.floor((now - start) / (1000 * 60));
|
|
842
842
|
return `${diffInMinutes} minutes`;
|
|
843
843
|
}
|
|
844
|
+
function prependPathEntry(existingPath, entry) {
|
|
845
|
+
if (!existingPath)
|
|
846
|
+
return entry;
|
|
847
|
+
const parts = existingPath.split(delimiter).filter(Boolean);
|
|
848
|
+
const normalizedEntry = process.platform === "win32" ? entry.toLowerCase() : entry;
|
|
849
|
+
const deduped = parts.filter((part) => {
|
|
850
|
+
const normalizedPart = process.platform === "win32" ? part.toLowerCase() : part;
|
|
851
|
+
return normalizedPart !== normalizedEntry;
|
|
852
|
+
});
|
|
853
|
+
return [entry, ...deduped].join(delimiter);
|
|
854
|
+
}
|
|
844
855
|
function parseCommandEnv(command) {
|
|
845
856
|
const env = {};
|
|
846
857
|
const trimmed = command.trim();
|
|
@@ -882,6 +893,8 @@ function buildManagedProcessEnv(parentEnv, processEnv = {}) {
|
|
|
882
893
|
continue;
|
|
883
894
|
sanitizedParentEnv[key] = value;
|
|
884
895
|
}
|
|
896
|
+
const bunDir = dirname(process.execPath);
|
|
897
|
+
sanitizedParentEnv.PATH = prependPathEntry(sanitizedParentEnv.PATH, bunDir);
|
|
885
898
|
return { ...sanitizedParentEnv, ...processEnv };
|
|
886
899
|
}
|
|
887
900
|
function stringifyEnvString(env) {
|
package/dist/index.js
CHANGED
|
@@ -826,7 +826,7 @@ var init_db = __esm(() => {
|
|
|
826
826
|
// src/utils.ts
|
|
827
827
|
import * as fs2 from "fs";
|
|
828
828
|
import * as os2 from "os";
|
|
829
|
-
import { join as join3 } from "path";
|
|
829
|
+
import { delimiter, dirname, join as join3 } from "path";
|
|
830
830
|
function parseEnvString(envString) {
|
|
831
831
|
const env = {};
|
|
832
832
|
envString.split(",").forEach((pair) => {
|
|
@@ -842,6 +842,17 @@ function calculateRuntime(startTime) {
|
|
|
842
842
|
const diffInMinutes = Math.floor((now - start) / (1000 * 60));
|
|
843
843
|
return `${diffInMinutes} minutes`;
|
|
844
844
|
}
|
|
845
|
+
function prependPathEntry(existingPath, entry) {
|
|
846
|
+
if (!existingPath)
|
|
847
|
+
return entry;
|
|
848
|
+
const parts = existingPath.split(delimiter).filter(Boolean);
|
|
849
|
+
const normalizedEntry = process.platform === "win32" ? entry.toLowerCase() : entry;
|
|
850
|
+
const deduped = parts.filter((part) => {
|
|
851
|
+
const normalizedPart = process.platform === "win32" ? part.toLowerCase() : part;
|
|
852
|
+
return normalizedPart !== normalizedEntry;
|
|
853
|
+
});
|
|
854
|
+
return [entry, ...deduped].join(delimiter);
|
|
855
|
+
}
|
|
845
856
|
function parseCommandEnv(command) {
|
|
846
857
|
const env = {};
|
|
847
858
|
const trimmed = command.trim();
|
|
@@ -883,6 +894,8 @@ function buildManagedProcessEnv(parentEnv, processEnv = {}) {
|
|
|
883
894
|
continue;
|
|
884
895
|
sanitizedParentEnv[key] = value;
|
|
885
896
|
}
|
|
897
|
+
const bunDir = dirname(process.execPath);
|
|
898
|
+
sanitizedParentEnv.PATH = prependPathEntry(sanitizedParentEnv.PATH, bunDir);
|
|
886
899
|
return { ...sanitizedParentEnv, ...processEnv };
|
|
887
900
|
}
|
|
888
901
|
function stringifyEnvString(env) {
|
|
@@ -1341,79 +1354,28 @@ import { join as join4 } from "path";
|
|
|
1341
1354
|
|
|
1342
1355
|
// src/cli-helpers.ts
|
|
1343
1356
|
init_db();
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
"
|
|
1347
|
-
"
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
"december"
|
|
1357
|
-
];
|
|
1358
|
-
var DAY_NAMES = [
|
|
1359
|
-
"",
|
|
1360
|
-
"first",
|
|
1361
|
-
"second",
|
|
1362
|
-
"third",
|
|
1363
|
-
"fourth",
|
|
1364
|
-
"fifth",
|
|
1365
|
-
"sixth",
|
|
1366
|
-
"seventh",
|
|
1367
|
-
"eighth",
|
|
1368
|
-
"ninth",
|
|
1369
|
-
"tenth",
|
|
1370
|
-
"eleventh",
|
|
1371
|
-
"twelfth",
|
|
1372
|
-
"thirteenth",
|
|
1373
|
-
"fourteenth",
|
|
1374
|
-
"fifteenth",
|
|
1375
|
-
"sixteenth",
|
|
1376
|
-
"seventeenth",
|
|
1377
|
-
"eighteenth",
|
|
1378
|
-
"nineteenth",
|
|
1379
|
-
"twentieth",
|
|
1380
|
-
"twenty-first",
|
|
1381
|
-
"twenty-second",
|
|
1382
|
-
"twenty-third",
|
|
1383
|
-
"twenty-fourth",
|
|
1384
|
-
"twenty-fifth",
|
|
1385
|
-
"twenty-sixth",
|
|
1386
|
-
"twenty-seventh",
|
|
1387
|
-
"twenty-eighth",
|
|
1388
|
-
"twenty-ninth",
|
|
1389
|
-
"thirtieth",
|
|
1390
|
-
"thirty-first"
|
|
1391
|
-
];
|
|
1392
|
-
function pad2(value) {
|
|
1393
|
-
return String(value).padStart(2, "0");
|
|
1394
|
-
}
|
|
1395
|
-
function buildDateProcessName(now = new Date) {
|
|
1396
|
-
const month = MONTH_NAMES[now.getMonth()] || "process";
|
|
1397
|
-
const day = DAY_NAMES[now.getDate()] || "day";
|
|
1398
|
-
return `${month}-${day}`;
|
|
1399
|
-
}
|
|
1400
|
-
function generateAutoProcessName(now = new Date) {
|
|
1401
|
-
const baseName = buildDateProcessName(now);
|
|
1357
|
+
import { basename, resolve } from "path";
|
|
1358
|
+
function sanitizeProcessName(value) {
|
|
1359
|
+
const normalized = value.trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/-+/g, "-").replace(/^[-._]+|[-._]+$/g, "");
|
|
1360
|
+
return normalized || "process";
|
|
1361
|
+
}
|
|
1362
|
+
function buildDirectoryProcessName(directory) {
|
|
1363
|
+
const resolved = resolve(directory);
|
|
1364
|
+
const folderName = basename(resolved);
|
|
1365
|
+
return sanitizeProcessName(folderName);
|
|
1366
|
+
}
|
|
1367
|
+
function generateAutoProcessName(directory) {
|
|
1368
|
+
const baseName = buildDirectoryProcessName(directory);
|
|
1402
1369
|
if (!getProcess(baseName)) {
|
|
1403
1370
|
return baseName;
|
|
1404
1371
|
}
|
|
1405
|
-
const timeSuffix = `${pad2(now.getHours())}${pad2(now.getMinutes())}${pad2(now.getSeconds())}`;
|
|
1406
|
-
const timeName = `${baseName}-${timeSuffix}`;
|
|
1407
|
-
if (!getProcess(timeName)) {
|
|
1408
|
-
return timeName;
|
|
1409
|
-
}
|
|
1410
1372
|
for (let i = 1;i < 1000; i++) {
|
|
1411
|
-
const candidate = `${
|
|
1373
|
+
const candidate = `${baseName}-${i}`;
|
|
1412
1374
|
if (!getProcess(candidate)) {
|
|
1413
1375
|
return candidate;
|
|
1414
1376
|
}
|
|
1415
1377
|
}
|
|
1416
|
-
return `${
|
|
1378
|
+
return `${baseName}-${Date.now()}`;
|
|
1417
1379
|
}
|
|
1418
1380
|
function shellQuoteArg(arg) {
|
|
1419
1381
|
if (process.platform === "win32") {
|
|
@@ -2039,7 +2001,18 @@ function formatMemory(bytes) {
|
|
|
2039
2001
|
}
|
|
2040
2002
|
async function showAll(opts) {
|
|
2041
2003
|
const processes = getAllProcesses();
|
|
2042
|
-
const
|
|
2004
|
+
const latestByName = new Map;
|
|
2005
|
+
for (const proc of processes) {
|
|
2006
|
+
const existing = latestByName.get(proc.name);
|
|
2007
|
+
if (!existing) {
|
|
2008
|
+
latestByName.set(proc.name, proc);
|
|
2009
|
+
continue;
|
|
2010
|
+
}
|
|
2011
|
+
if (proc.timestamp > existing.timestamp || proc.timestamp === existing.timestamp && proc.id > existing.id) {
|
|
2012
|
+
latestByName.set(proc.name, proc);
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
const filtered = Array.from(latestByName.values()).filter((proc) => {
|
|
2043
2016
|
if (isInternalProcessName(proc.name))
|
|
2044
2017
|
return false;
|
|
2045
2018
|
if (!opts?.filter)
|
|
@@ -2071,9 +2044,19 @@ async function showAll(opts) {
|
|
|
2071
2044
|
for (const proc of filtered) {
|
|
2072
2045
|
const isRunning = aliveCache.get(proc.pid) ?? await isProcessRunning(proc.pid, proc.command);
|
|
2073
2046
|
const envVars = parseEnvString(proc.env);
|
|
2074
|
-
|
|
2047
|
+
let displayPid = proc.pid;
|
|
2048
|
+
let ports = [];
|
|
2049
|
+
if (isRunning) {
|
|
2050
|
+
const resolved = await resolvePidWithPorts(proc.pid);
|
|
2051
|
+
displayPid = resolved.pid;
|
|
2052
|
+
ports = resolved.ports;
|
|
2053
|
+
if (displayPid !== proc.pid) {
|
|
2054
|
+
updateProcessPid(proc.name, displayPid);
|
|
2055
|
+
proc.pid = displayPid;
|
|
2056
|
+
}
|
|
2057
|
+
}
|
|
2075
2058
|
jsonData.push({
|
|
2076
|
-
pid:
|
|
2059
|
+
pid: displayPid,
|
|
2077
2060
|
name: proc.name,
|
|
2078
2061
|
ports: ports.length > 0 ? ports : undefined,
|
|
2079
2062
|
status: isRunning ? "running" : "stopped",
|
|
@@ -2334,7 +2317,7 @@ ${color(content)}
|
|
|
2334
2317
|
return true;
|
|
2335
2318
|
};
|
|
2336
2319
|
const waitForLogReady = (logPath, timeoutMs = 5000) => {
|
|
2337
|
-
return new Promise((
|
|
2320
|
+
return new Promise((resolve2, reject) => {
|
|
2338
2321
|
const checkReady = () => {
|
|
2339
2322
|
try {
|
|
2340
2323
|
if (fs4.existsSync(logPath)) {
|
|
@@ -2347,7 +2330,7 @@ ${color(content)}
|
|
|
2347
2330
|
return false;
|
|
2348
2331
|
};
|
|
2349
2332
|
if (checkReady()) {
|
|
2350
|
-
|
|
2333
|
+
resolve2();
|
|
2351
2334
|
return;
|
|
2352
2335
|
}
|
|
2353
2336
|
const dir = path2.dirname(logPath);
|
|
@@ -2356,7 +2339,7 @@ ${color(content)}
|
|
|
2356
2339
|
if (changedFilename === filename && eventType === "change") {
|
|
2357
2340
|
if (checkReady()) {
|
|
2358
2341
|
watcher2.close();
|
|
2359
|
-
|
|
2342
|
+
resolve2();
|
|
2360
2343
|
}
|
|
2361
2344
|
}
|
|
2362
2345
|
});
|
|
@@ -2874,7 +2857,7 @@ async function showHelp() {
|
|
|
2874
2857
|
${chalk7.yellow("Commands:")}
|
|
2875
2858
|
bunx bgrun List all processes
|
|
2876
2859
|
bunx bgrun [name] Show details for a process
|
|
2877
|
-
bunx bgrun -- <cmd> Start a managed process
|
|
2860
|
+
bunx bgrun -- <cmd> Start a managed process named from the working directory
|
|
2878
2861
|
bunx bgrun inline -- <cmd> Run a command in this terminal with config env loaded
|
|
2879
2862
|
bunx bgrun --env Print shell commands to export config env vars
|
|
2880
2863
|
bunx bgrun --dashboard Launch web dashboard (managed by bgrun)
|
|
@@ -2897,6 +2880,7 @@ async function showHelp() {
|
|
|
2897
2880
|
--env Print shell export commands from config and exit
|
|
2898
2881
|
--shell <type> Shell for --env: powershell | cmd | sh | json
|
|
2899
2882
|
--watch Watch for file changes and auto-restart
|
|
2883
|
+
--hot Restart the managed process when files change
|
|
2900
2884
|
--force Force restart existing process
|
|
2901
2885
|
--fetch Fetch latest git changes before running
|
|
2902
2886
|
--json Output in JSON format
|
|
@@ -2915,6 +2899,7 @@ async function showHelp() {
|
|
|
2915
2899
|
|
|
2916
2900
|
${chalk7.yellow("Examples:")}
|
|
2917
2901
|
bunx bgrun -- bun run dev
|
|
2902
|
+
bunx bgrun --hot -- bun run index.ts
|
|
2918
2903
|
bunx bgrun --no-config -- bun run script.ts
|
|
2919
2904
|
bunx bgrun --force -- bun run server.ts
|
|
2920
2905
|
bunx bgrun inline -- bun run dev
|
|
@@ -2937,6 +2922,7 @@ var cliArgOptions = {
|
|
|
2937
2922
|
env: { type: "boolean" },
|
|
2938
2923
|
shell: { type: "string" },
|
|
2939
2924
|
watch: { type: "boolean" },
|
|
2925
|
+
hot: { type: "boolean" },
|
|
2940
2926
|
force: { type: "boolean" },
|
|
2941
2927
|
fetch: { type: "boolean" },
|
|
2942
2928
|
delete: { type: "boolean" },
|
|
@@ -2968,7 +2954,7 @@ var cliArgOptions = {
|
|
|
2968
2954
|
async function run2() {
|
|
2969
2955
|
const rawArgs = Bun.argv.slice(2);
|
|
2970
2956
|
const isActionInvocation = (values2) => {
|
|
2971
|
-
return Boolean(values2.dashboard || values2.guard || values2["guard-off"] || values2.version || values2.help || values2.debug || values2.nuke || values2.clean || values2["restart-all"] || values2["stop-all"] || values2.delete || values2.restart || values2.stop || values2.logs || values2["log-stdout"] || values2["log-stderr"] || values2.watch || values2.json || values2.filter);
|
|
2957
|
+
return Boolean(values2.dashboard || values2.guard || values2["guard-off"] || values2.version || values2.help || values2.debug || values2.nuke || values2.clean || values2["restart-all"] || values2["stop-all"] || values2.delete || values2.restart || values2.stop || values2.logs || values2["log-stdout"] || values2["log-stderr"] || values2.watch || values2.hot || values2.json || values2.filter);
|
|
2972
2958
|
};
|
|
2973
2959
|
if (rawArgs[0] === "inline") {
|
|
2974
2960
|
const parsed = parseInlineArgs(rawArgs.slice(1));
|
|
@@ -3001,11 +2987,12 @@ async function run2() {
|
|
|
3001
2987
|
strict: false,
|
|
3002
2988
|
allowPositionals: true
|
|
3003
2989
|
});
|
|
3004
|
-
const autoName = values2.name || generateAutoProcessName();
|
|
3005
2990
|
const inlineCommand = joinCommandArgs(commandArgs);
|
|
3006
2991
|
const directory = values2.directory || process.cwd();
|
|
3007
|
-
|
|
3008
|
-
|
|
2992
|
+
const autoName = values2.name || generateAutoProcessName(directory);
|
|
2993
|
+
const watchLike = Boolean(values2.watch || values2.hot);
|
|
2994
|
+
const runOptions = {
|
|
2995
|
+
action: watchLike ? "watch" : "run",
|
|
3009
2996
|
name: autoName,
|
|
3010
2997
|
command: inlineCommand,
|
|
3011
2998
|
directory,
|
|
@@ -3016,7 +3003,16 @@ async function run2() {
|
|
|
3016
3003
|
dbPath: values2.db,
|
|
3017
3004
|
stdout: values2.stdout,
|
|
3018
3005
|
stderr: values2.stderr
|
|
3019
|
-
}
|
|
3006
|
+
};
|
|
3007
|
+
if (watchLike) {
|
|
3008
|
+
await handleWatch(runOptions, {
|
|
3009
|
+
showLogs: values2.logs || false,
|
|
3010
|
+
logType: values2["log-stdout"] ? "stdout" : values2["log-stderr"] ? "stderr" : "both",
|
|
3011
|
+
lines: values2.lines ? parseInt(values2.lines) : undefined
|
|
3012
|
+
});
|
|
3013
|
+
} else {
|
|
3014
|
+
await handleRun(runOptions);
|
|
3015
|
+
}
|
|
3020
3016
|
return;
|
|
3021
3017
|
}
|
|
3022
3018
|
const { values, positionals } = parseArgs({
|
|
@@ -3037,11 +3033,12 @@ async function run2() {
|
|
|
3037
3033
|
return;
|
|
3038
3034
|
}
|
|
3039
3035
|
if (positionals.length > 1 && !values.command && !isActionInvocation(values)) {
|
|
3040
|
-
const autoName = values.name || generateAutoProcessName();
|
|
3041
3036
|
const implicitCommand = joinCommandArgs(positionals);
|
|
3042
3037
|
const directory = values.directory || process.cwd();
|
|
3043
|
-
|
|
3044
|
-
|
|
3038
|
+
const autoName = values.name || generateAutoProcessName(directory);
|
|
3039
|
+
const watchLike = Boolean(values.watch || values.hot);
|
|
3040
|
+
const runOptions = {
|
|
3041
|
+
action: watchLike ? "watch" : "run",
|
|
3045
3042
|
name: autoName,
|
|
3046
3043
|
command: implicitCommand,
|
|
3047
3044
|
directory,
|
|
@@ -3052,7 +3049,16 @@ async function run2() {
|
|
|
3052
3049
|
dbPath: values.db,
|
|
3053
3050
|
stdout: values.stdout,
|
|
3054
3051
|
stderr: values.stderr
|
|
3055
|
-
}
|
|
3052
|
+
};
|
|
3053
|
+
if (watchLike) {
|
|
3054
|
+
await handleWatch(runOptions, {
|
|
3055
|
+
showLogs: values.logs || false,
|
|
3056
|
+
logType: values["log-stdout"] ? "stdout" : values["log-stderr"] ? "stderr" : "both",
|
|
3057
|
+
lines: values.lines ? parseInt(values.lines) : undefined
|
|
3058
|
+
});
|
|
3059
|
+
} else {
|
|
3060
|
+
await handleRun(runOptions);
|
|
3061
|
+
}
|
|
3056
3062
|
return;
|
|
3057
3063
|
}
|
|
3058
3064
|
if (values["_serve"]) {
|
|
@@ -3321,7 +3327,7 @@ async function run2() {
|
|
|
3321
3327
|
await showLogs(name, logType, lines);
|
|
3322
3328
|
return;
|
|
3323
3329
|
}
|
|
3324
|
-
if (values.watch) {
|
|
3330
|
+
if (values.watch || values.hot) {
|
|
3325
3331
|
await handleWatch({
|
|
3326
3332
|
action: "watch",
|
|
3327
3333
|
name,
|