@base44-preview/cli 0.1.12-pr.595.db709c9 → 0.1.12-pr.595.e3f5cae
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 +50 -28
- package/dist/cli/index.js.map +4 -4
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -247842,6 +247842,10 @@ async function* readLines(body) {
|
|
|
247842
247842
|
async function* readStreamEvents(body) {
|
|
247843
247843
|
let eventName = "";
|
|
247844
247844
|
for await (const line of readLines(body)) {
|
|
247845
|
+
if (line.startsWith(":")) {
|
|
247846
|
+
yield { kind: "ping" };
|
|
247847
|
+
continue;
|
|
247848
|
+
}
|
|
247845
247849
|
if (line.startsWith("event:")) {
|
|
247846
247850
|
eventName = line.slice(6).trim();
|
|
247847
247851
|
continue;
|
|
@@ -258480,12 +258484,14 @@ function streamEventToLogEntry(event) {
|
|
|
258480
258484
|
}
|
|
258481
258485
|
async function printStreamUntilEnd(stream, levelFilter, jsonMode, startTime) {
|
|
258482
258486
|
let lastTime = startTime;
|
|
258483
|
-
let
|
|
258487
|
+
let provedAlive = false;
|
|
258484
258488
|
try {
|
|
258485
258489
|
for await (const event of stream) {
|
|
258486
|
-
|
|
258490
|
+
provedAlive = true;
|
|
258487
258491
|
if (event.kind === "end")
|
|
258488
|
-
return { lastTime,
|
|
258492
|
+
return { lastTime, provedAlive, end: event.end };
|
|
258493
|
+
if (event.kind === "ping")
|
|
258494
|
+
continue;
|
|
258489
258495
|
if (levelFilter && event.log.level !== levelFilter)
|
|
258490
258496
|
continue;
|
|
258491
258497
|
writeFollowLine(streamEventToLogEntry(event.log), jsonMode);
|
|
@@ -258493,11 +258499,13 @@ async function printStreamUntilEnd(stream, levelFilter, jsonMode, startTime) {
|
|
|
258493
258499
|
lastTime = event.log.time;
|
|
258494
258500
|
}
|
|
258495
258501
|
} catch {}
|
|
258496
|
-
return { lastTime,
|
|
258502
|
+
return { lastTime, provedAlive, end: null };
|
|
258497
258503
|
}
|
|
258498
258504
|
var STREAM_RECONNECT_DELAY_MS = 1000;
|
|
258499
258505
|
var MAX_DROPS_SINCE_LAST_EVENT = 2;
|
|
258500
258506
|
var CONNECT_RETRY_DELAYS_MS = [1000, 2000, 4000, 8000];
|
|
258507
|
+
var countDropTowardGivingUp = (dropsSinceLastEvent, provedAlive) => provedAlive ? 1 : dropsSinceLastEvent + 1;
|
|
258508
|
+
var shouldGiveUpStreaming = (dropsSinceLastEvent) => dropsSinceLastEvent >= MAX_DROPS_SINCE_LAST_EVENT;
|
|
258501
258509
|
async function connectWhileTransientlyUnavailable(filters) {
|
|
258502
258510
|
let attempt = await openLogStream(filters);
|
|
258503
258511
|
for (const retryDelay of CONNECT_RETRY_DELAYS_MS) {
|
|
@@ -258508,42 +258516,56 @@ async function connectWhileTransientlyUnavailable(filters) {
|
|
|
258508
258516
|
}
|
|
258509
258517
|
return attempt;
|
|
258510
258518
|
}
|
|
258511
|
-
async function streamUntilExhausted(options, jsonMode) {
|
|
258512
|
-
|
|
258513
|
-
functions: parseFunctionNames(options.function),
|
|
258514
|
-
env: options.env
|
|
258515
|
-
};
|
|
258516
|
-
let everConnected = false;
|
|
258519
|
+
async function streamUntilExhausted(firstStream, filters, options, jsonMode) {
|
|
258520
|
+
let events = firstStream;
|
|
258517
258521
|
let lastTime = "";
|
|
258518
258522
|
let dropsSinceLastEvent = 0;
|
|
258519
258523
|
while (true) {
|
|
258520
|
-
const
|
|
258521
|
-
if (attempt.kind !== "stream")
|
|
258522
|
-
break;
|
|
258523
|
-
everConnected = true;
|
|
258524
|
-
const ending = await printStreamUntilEnd(attempt.events, options.level, jsonMode, lastTime);
|
|
258524
|
+
const ending = await printStreamUntilEnd(events, options.level, jsonMode, lastTime);
|
|
258525
258525
|
lastTime = ending.lastTime;
|
|
258526
258526
|
if (ending.end) {
|
|
258527
258527
|
if (!ending.end.retriable)
|
|
258528
|
-
|
|
258528
|
+
return;
|
|
258529
258529
|
dropsSinceLastEvent = 0;
|
|
258530
258530
|
} else {
|
|
258531
|
-
dropsSinceLastEvent = ending.
|
|
258532
|
-
if (dropsSinceLastEvent
|
|
258533
|
-
|
|
258531
|
+
dropsSinceLastEvent = countDropTowardGivingUp(dropsSinceLastEvent, ending.provedAlive);
|
|
258532
|
+
if (shouldGiveUpStreaming(dropsSinceLastEvent))
|
|
258533
|
+
return;
|
|
258534
258534
|
}
|
|
258535
258535
|
await delay2(STREAM_RECONNECT_DELAY_MS);
|
|
258536
|
+
const reopened = await connectWhileTransientlyUnavailable(filters);
|
|
258537
|
+
if (reopened.kind !== "stream")
|
|
258538
|
+
return;
|
|
258539
|
+
events = reopened.events;
|
|
258536
258540
|
}
|
|
258537
|
-
return { everConnected, lastTime };
|
|
258538
258541
|
}
|
|
258539
|
-
|
|
258540
|
-
|
|
258541
|
-
|
|
258542
|
-
|
|
258543
|
-
|
|
258544
|
-
|
|
258542
|
+
function streamLostError() {
|
|
258543
|
+
return new ApiError("The realtime log stream stopped and could not be re-established", {
|
|
258544
|
+
hints: [
|
|
258545
|
+
{ message: "Start a new live tail", command: "base44 logs --follow" },
|
|
258546
|
+
{
|
|
258547
|
+
message: "Or read recent logs without streaming",
|
|
258548
|
+
command: "base44 logs"
|
|
258549
|
+
}
|
|
258550
|
+
]
|
|
258545
258551
|
});
|
|
258546
258552
|
}
|
|
258553
|
+
async function followLogs(functionNames, options, availableFunctionNames, jsonMode, logger2) {
|
|
258554
|
+
const filters = {
|
|
258555
|
+
functions: parseFunctionNames(options.function),
|
|
258556
|
+
env: options.env
|
|
258557
|
+
};
|
|
258558
|
+
const opened = await connectWhileTransientlyUnavailable(filters);
|
|
258559
|
+
if (opened.kind !== "stream") {
|
|
258560
|
+
logger2.warn(opened.kind === "refused" ? "Realtime logs are not available for this app — falling back to polling (lines may lag ~20-30s)." : "Could not reach the realtime log stream — falling back to polling (lines may lag ~20-30s).");
|
|
258561
|
+
return pollLogs(functionNames, options, availableFunctionNames, jsonMode, {
|
|
258562
|
+
lastTime: "",
|
|
258563
|
+
boundaryKeys: new Set
|
|
258564
|
+
});
|
|
258565
|
+
}
|
|
258566
|
+
await streamUntilExhausted(opened.events, filters, options, jsonMode);
|
|
258567
|
+
throw streamLostError();
|
|
258568
|
+
}
|
|
258547
258569
|
async function pollLogs(functionNames, options, availableFunctionNames, jsonMode, initialState) {
|
|
258548
258570
|
let state = initialState;
|
|
258549
258571
|
let first = state.lastTime === "";
|
|
@@ -258677,7 +258699,7 @@ async function logsAction(ctx, options) {
|
|
|
258677
258699
|
function getLogsCommand() {
|
|
258678
258700
|
return new Base44Command("logs").description("Fetch function logs for this app").option("--function <names>", "Filter by function name(s), comma-separated. If omitted, fetches logs for all deployed functions").option("--since <datetime>", "Show logs from this time. ISO datetime or relative shorthand (e.g. 1h, 30m, 2d)", normalizeDatetime).option("--until <datetime>", "Show logs until this time. ISO datetime or relative shorthand (e.g. 1h, 30m, 2d)", normalizeDatetime).addOption(new Option("--level <level>", "Filter by log level").choices([
|
|
258679
258701
|
...LogLevelSchema.options
|
|
258680
|
-
])).option("-n, --limit <n>", "Results per page (1-1000
|
|
258702
|
+
])).option("-n, --limit <n>", "Results per page (1-1000; the server returns at most 500)").option("-f, --follow", "Stream new logs as they arrive").addOption(new Option("--order <order>", "Sort order").choices(["asc", "desc"])).addOption(new Option("--env <env>", "Which deployment to read logs from: preview (current draft) or prod (published). Default: preview").choices([...LogEnvSchema.options])).action(logsAction);
|
|
258681
258703
|
}
|
|
258682
258704
|
|
|
258683
258705
|
// src/cli/commands/project/scaffold.ts
|
|
@@ -268307,4 +268329,4 @@ export {
|
|
|
268307
268329
|
runCLI
|
|
268308
268330
|
};
|
|
268309
268331
|
|
|
268310
|
-
//# debugId=
|
|
268332
|
+
//# debugId=2322876375B5637364756E2164756E21
|