@base44-preview/cli 0.1.12-pr.595.e3f5cae → 0.1.12-pr.609.40d5d07
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 +33 -264
- package/dist/cli/index.js.map +5 -6
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -120898,7 +120898,7 @@ function parse42(toml, { maxDepth = 1000, integersAsBigInt } = {}) {
|
|
|
120898
120898
|
}
|
|
120899
120899
|
return res;
|
|
120900
120900
|
}
|
|
120901
|
-
async function
|
|
120901
|
+
async function readFile5(file2) {
|
|
120902
120902
|
if (isUrlString(file2)) {
|
|
120903
120903
|
file2 = new URL(file2);
|
|
120904
120904
|
}
|
|
@@ -134692,7 +134692,7 @@ ${codeblock}`, options8);
|
|
|
134692
134692
|
"\\": "\\"
|
|
134693
134693
|
};
|
|
134694
134694
|
KEY_PART_RE = /^[a-zA-Z0-9-_]+[ \t]*$/;
|
|
134695
|
-
read_file_default =
|
|
134695
|
+
read_file_default = readFile5;
|
|
134696
134696
|
loadConfigFromPackageJson = process.versions.bun ? async function loadConfigFromBunPackageJson(file2) {
|
|
134697
134697
|
const { prettier } = await readBunPackageJson(file2);
|
|
134698
134698
|
return prettier;
|
|
@@ -143927,7 +143927,7 @@ var require_parse7 = __commonJS(function(exports) {
|
|
|
143927
143927
|
extension: url3.getExtension(path18)
|
|
143928
143928
|
};
|
|
143929
143929
|
try {
|
|
143930
|
-
const resolver = await
|
|
143930
|
+
const resolver = await readFile6(file2, options8, $refs);
|
|
143931
143931
|
$ref.pathType = resolver.plugin.name;
|
|
143932
143932
|
file2.data = resolver.result;
|
|
143933
143933
|
const parser2 = await parseFile(file2, options8, $refs);
|
|
@@ -143940,7 +143940,7 @@ var require_parse7 = __commonJS(function(exports) {
|
|
|
143940
143940
|
throw err;
|
|
143941
143941
|
}
|
|
143942
143942
|
}
|
|
143943
|
-
async function
|
|
143943
|
+
async function readFile6(file2, options8, $refs) {
|
|
143944
143944
|
let resolvers = plugins.all(options8.resolve);
|
|
143945
143945
|
resolvers = plugins.filter(resolvers, "canRead", file2);
|
|
143946
143946
|
plugins.sort(resolvers);
|
|
@@ -221223,7 +221223,7 @@ var require_dist5 = __commonJS(function(exports, module) {
|
|
|
221223
221223
|
});
|
|
221224
221224
|
module.exports = __toCommonJS2(src_exports);
|
|
221225
221225
|
var import_promises25 = __require("node:fs/promises");
|
|
221226
|
-
var
|
|
221226
|
+
var import_node_fs25 = __require("node:fs");
|
|
221227
221227
|
var DEVIN_LOCAL_PATH = "/opt/.devin";
|
|
221228
221228
|
var CURSOR2 = "cursor";
|
|
221229
221229
|
var CURSOR_CLI = "cursor-cli";
|
|
@@ -221280,7 +221280,7 @@ var require_dist5 = __commonJS(function(exports, module) {
|
|
|
221280
221280
|
return { isAgent: true, agent: { name: REPLIT } };
|
|
221281
221281
|
}
|
|
221282
221282
|
try {
|
|
221283
|
-
await (0, import_promises25.access)(DEVIN_LOCAL_PATH,
|
|
221283
|
+
await (0, import_promises25.access)(DEVIN_LOCAL_PATH, import_node_fs25.constants.F_OK);
|
|
221284
221284
|
return { isAgent: true, agent: { name: DEVIN } };
|
|
221285
221285
|
} catch (error48) {}
|
|
221286
221286
|
return { isAgent: false, agent: undefined };
|
|
@@ -247752,141 +247752,6 @@ var functionResource = {
|
|
|
247752
247752
|
readAll: readAllFunctions,
|
|
247753
247753
|
push: (functions) => deployFunctionsSequentially(functions)
|
|
247754
247754
|
};
|
|
247755
|
-
// src/core/resources/function/stream-api.ts
|
|
247756
|
-
var StreamLogEventSchema = exports_external.object({
|
|
247757
|
-
time: exports_external.string(),
|
|
247758
|
-
level: exports_external.preprocess((value) => value === "warn" ? "warning" : value, LogLevelSchema),
|
|
247759
|
-
function: exports_external.string().nullable(),
|
|
247760
|
-
message: exports_external.string()
|
|
247761
|
-
});
|
|
247762
|
-
var StreamEndEventSchema = exports_external.object({
|
|
247763
|
-
reason: exports_external.string(),
|
|
247764
|
-
retriable: exports_external.boolean()
|
|
247765
|
-
});
|
|
247766
|
-
function buildStreamUrl(filters) {
|
|
247767
|
-
const { id } = getAppContext();
|
|
247768
|
-
const url2 = new URL(`/api/apps/${id}/functions-mgmt/logs/stream`, getBase44ApiUrl());
|
|
247769
|
-
if (filters.functions?.length) {
|
|
247770
|
-
url2.searchParams.set("function", filters.functions.join(","));
|
|
247771
|
-
}
|
|
247772
|
-
if (filters.env) {
|
|
247773
|
-
url2.searchParams.set("env", filters.env);
|
|
247774
|
-
}
|
|
247775
|
-
return url2.href;
|
|
247776
|
-
}
|
|
247777
|
-
async function buildStreamAuthHeaders() {
|
|
247778
|
-
const workspaceApiKey = getWorkspaceApiKeyFromEnv();
|
|
247779
|
-
if (workspaceApiKey && isWorkspaceApiKey(workspaceApiKey)) {
|
|
247780
|
-
return { api_key: workspaceApiKey };
|
|
247781
|
-
}
|
|
247782
|
-
const auth = await readAuth();
|
|
247783
|
-
if (isTokenExpired(auth)) {
|
|
247784
|
-
const refreshedToken = await refreshAndSaveTokens();
|
|
247785
|
-
if (refreshedToken) {
|
|
247786
|
-
return { Authorization: `Bearer ${refreshedToken}` };
|
|
247787
|
-
}
|
|
247788
|
-
}
|
|
247789
|
-
return { Authorization: `Bearer ${auth.accessToken}` };
|
|
247790
|
-
}
|
|
247791
|
-
function parseStreamEvent(eventName, data) {
|
|
247792
|
-
try {
|
|
247793
|
-
const payload = JSON.parse(data);
|
|
247794
|
-
if (eventName === "end") {
|
|
247795
|
-
const result = StreamEndEventSchema.safeParse(payload);
|
|
247796
|
-
return result.success ? { kind: "end", end: result.data } : null;
|
|
247797
|
-
}
|
|
247798
|
-
if (eventName === "") {
|
|
247799
|
-
const result = StreamLogEventSchema.safeParse(payload);
|
|
247800
|
-
return result.success ? { kind: "log", log: result.data } : null;
|
|
247801
|
-
}
|
|
247802
|
-
return null;
|
|
247803
|
-
} catch {
|
|
247804
|
-
return null;
|
|
247805
|
-
}
|
|
247806
|
-
}
|
|
247807
|
-
var STREAM_SILENCE_TIMEOUT_MS = 60000;
|
|
247808
|
-
async function readOrSilence(reader) {
|
|
247809
|
-
let timer;
|
|
247810
|
-
const silence = new Promise((resolve3) => {
|
|
247811
|
-
timer = setTimeout(() => resolve3("silence"), STREAM_SILENCE_TIMEOUT_MS);
|
|
247812
|
-
});
|
|
247813
|
-
try {
|
|
247814
|
-
return await Promise.race([reader.read(), silence]);
|
|
247815
|
-
} finally {
|
|
247816
|
-
clearTimeout(timer);
|
|
247817
|
-
}
|
|
247818
|
-
}
|
|
247819
|
-
async function* readLines(body) {
|
|
247820
|
-
const reader = body.getReader();
|
|
247821
|
-
const decoder = new TextDecoder;
|
|
247822
|
-
let buffered = "";
|
|
247823
|
-
try {
|
|
247824
|
-
while (true) {
|
|
247825
|
-
const result = await readOrSilence(reader);
|
|
247826
|
-
if (result === "silence") {
|
|
247827
|
-
await reader.cancel();
|
|
247828
|
-
return;
|
|
247829
|
-
}
|
|
247830
|
-
if (result.done || !result.value)
|
|
247831
|
-
return;
|
|
247832
|
-
buffered += decoder.decode(result.value, { stream: true });
|
|
247833
|
-
const lines = buffered.split(`
|
|
247834
|
-
`);
|
|
247835
|
-
buffered = lines.pop() ?? "";
|
|
247836
|
-
yield* lines;
|
|
247837
|
-
}
|
|
247838
|
-
} finally {
|
|
247839
|
-
reader.releaseLock();
|
|
247840
|
-
}
|
|
247841
|
-
}
|
|
247842
|
-
async function* readStreamEvents(body) {
|
|
247843
|
-
let eventName = "";
|
|
247844
|
-
for await (const line of readLines(body)) {
|
|
247845
|
-
if (line.startsWith(":")) {
|
|
247846
|
-
yield { kind: "ping" };
|
|
247847
|
-
continue;
|
|
247848
|
-
}
|
|
247849
|
-
if (line.startsWith("event:")) {
|
|
247850
|
-
eventName = line.slice(6).trim();
|
|
247851
|
-
continue;
|
|
247852
|
-
}
|
|
247853
|
-
if (line.startsWith("data:")) {
|
|
247854
|
-
const event = parseStreamEvent(eventName, line.slice(5));
|
|
247855
|
-
eventName = "";
|
|
247856
|
-
if (event)
|
|
247857
|
-
yield event;
|
|
247858
|
-
continue;
|
|
247859
|
-
}
|
|
247860
|
-
if (line.trim() === "")
|
|
247861
|
-
eventName = "";
|
|
247862
|
-
}
|
|
247863
|
-
}
|
|
247864
|
-
var STREAM_CONNECT_TIMEOUT_MS = 1e4;
|
|
247865
|
-
var isWorthReconnecting = (status) => status >= 500;
|
|
247866
|
-
async function openLogStream(filters) {
|
|
247867
|
-
const connectPhase = new AbortController;
|
|
247868
|
-
const connectTimer = setTimeout(() => connectPhase.abort(), STREAM_CONNECT_TIMEOUT_MS);
|
|
247869
|
-
let response;
|
|
247870
|
-
try {
|
|
247871
|
-
response = await fetch(buildStreamUrl(filters), {
|
|
247872
|
-
headers: {
|
|
247873
|
-
Accept: "text/event-stream",
|
|
247874
|
-
...await buildStreamAuthHeaders()
|
|
247875
|
-
},
|
|
247876
|
-
signal: connectPhase.signal
|
|
247877
|
-
});
|
|
247878
|
-
} catch {
|
|
247879
|
-
return { kind: "transient" };
|
|
247880
|
-
} finally {
|
|
247881
|
-
clearTimeout(connectTimer);
|
|
247882
|
-
}
|
|
247883
|
-
if (!response.ok) {
|
|
247884
|
-
return isWorthReconnecting(response.status) ? { kind: "transient" } : { kind: "refused" };
|
|
247885
|
-
}
|
|
247886
|
-
if (!response.body)
|
|
247887
|
-
return { kind: "transient" };
|
|
247888
|
-
return { kind: "stream", events: readStreamEvents(response.body) };
|
|
247889
|
-
}
|
|
247890
247755
|
// src/core/project/config.ts
|
|
247891
247756
|
class ProjectConfigReader {
|
|
247892
247757
|
pluginSourceByNamespace = new Map;
|
|
@@ -248400,9 +248265,9 @@ async function createArchive(pathToArchive, targetArchivePath) {
|
|
|
248400
248265
|
}
|
|
248401
248266
|
// src/core/site/manifest.ts
|
|
248402
248267
|
import { createHash } from "node:crypto";
|
|
248403
|
-
import {
|
|
248268
|
+
import { createReadStream } from "node:fs";
|
|
248269
|
+
import { stat } from "node:fs/promises";
|
|
248404
248270
|
import { basename as basename4, join as join15 } from "node:path";
|
|
248405
|
-
var MAX_ASSET_SIZE_BYTES = 25 * 1024 * 1024;
|
|
248406
248271
|
var MAX_ASSET_COUNT = 1e5;
|
|
248407
248272
|
var ASSETS_IGNORE_FILE = ".assetsignore";
|
|
248408
248273
|
var ALWAYS_IGNORED = new Set([
|
|
@@ -248410,8 +248275,12 @@ var ALWAYS_IGNORED = new Set([
|
|
|
248410
248275
|
"wrangler.json",
|
|
248411
248276
|
".dev.vars"
|
|
248412
248277
|
]);
|
|
248413
|
-
function
|
|
248414
|
-
|
|
248278
|
+
async function hashAssetFile(appId, absolutePath) {
|
|
248279
|
+
const hash2 = createHash("sha256").update(Buffer.from(appId, "utf8"));
|
|
248280
|
+
for await (const chunk of createReadStream(absolutePath)) {
|
|
248281
|
+
hash2.update(chunk);
|
|
248282
|
+
}
|
|
248283
|
+
return hash2.digest("hex").slice(0, 32);
|
|
248415
248284
|
}
|
|
248416
248285
|
async function buildAssetManifest(assetsDir, appId) {
|
|
248417
248286
|
const manifest = {};
|
|
@@ -248430,11 +248299,7 @@ async function buildAssetManifest(assetsDir, appId) {
|
|
|
248430
248299
|
for (const relativePath of relativeFilePaths.sort()) {
|
|
248431
248300
|
const absolutePath = join15(assetsDir, ...relativePath.split("/"));
|
|
248432
248301
|
const { size } = await stat(absolutePath);
|
|
248433
|
-
|
|
248434
|
-
throw new InvalidInputError(`Static asset "${relativePath}" is ${size} bytes, which exceeds the 25 MiB per-file limit.`);
|
|
248435
|
-
}
|
|
248436
|
-
const content = await readFile2(absolutePath);
|
|
248437
|
-
const hash2 = hashAsset(appId, content);
|
|
248302
|
+
const hash2 = await hashAssetFile(appId, absolutePath);
|
|
248438
248303
|
manifest[`/${relativePath}`] = { hash: hash2, size };
|
|
248439
248304
|
if (!filesByHash.has(hash2)) {
|
|
248440
248305
|
filesByHash.set(hash2, { absolutePath, hash: hash2, size });
|
|
@@ -248443,11 +248308,11 @@ async function buildAssetManifest(assetsDir, appId) {
|
|
|
248443
248308
|
return { manifest, filesByHash };
|
|
248444
248309
|
}
|
|
248445
248310
|
// src/core/site/static-site.ts
|
|
248446
|
-
import { readFile as
|
|
248311
|
+
import { readFile as readFile3 } from "node:fs/promises";
|
|
248447
248312
|
import { join as join16 } from "node:path";
|
|
248448
248313
|
|
|
248449
248314
|
// src/core/site/upload.ts
|
|
248450
|
-
import { readFile as
|
|
248315
|
+
import { readFile as readFile2 } from "node:fs/promises";
|
|
248451
248316
|
|
|
248452
248317
|
// ../../node_modules/p-map/index.js
|
|
248453
248318
|
async function pMap(iterable, mapper, {
|
|
@@ -248593,7 +248458,7 @@ async function uploadPresignedAsset(upload, assets) {
|
|
|
248593
248458
|
if (!file2) {
|
|
248594
248459
|
throw new InternalError(`Server requested upload of unknown asset path: ${upload.path}`);
|
|
248595
248460
|
}
|
|
248596
|
-
const content = await
|
|
248461
|
+
const content = await readFile2(file2.absolutePath);
|
|
248597
248462
|
try {
|
|
248598
248463
|
await distribution_default.put(upload.url, {
|
|
248599
248464
|
body: new Uint8Array(content),
|
|
@@ -248630,7 +248495,7 @@ async function deployStaticSite(options) {
|
|
|
248630
248495
|
onProgress: progress?.onAssetUpload
|
|
248631
248496
|
});
|
|
248632
248497
|
}
|
|
248633
|
-
const indexHtml = await
|
|
248498
|
+
const indexHtml = await readFile3(join16(outputDir, "index.html"));
|
|
248634
248499
|
const finalized = await finalizeStaticDeployment(created.deploymentId, new Uint8Array(indexHtml), created.sessionId);
|
|
248635
248500
|
return { deploymentId: finalized.deploymentId };
|
|
248636
248501
|
}
|
|
@@ -253794,7 +253659,7 @@ var duplex = () => new Duplex({ read() {}, write() {} });
|
|
|
253794
253659
|
var handleDummyPromise = async (error48, verboseInfo, options) => handleResult(error48, verboseInfo, options);
|
|
253795
253660
|
|
|
253796
253661
|
// ../../node_modules/execa/lib/stdio/handle-async.js
|
|
253797
|
-
import { createReadStream, createWriteStream } from "node:fs";
|
|
253662
|
+
import { createReadStream as createReadStream2, createWriteStream } from "node:fs";
|
|
253798
253663
|
import { Buffer as Buffer5 } from "node:buffer";
|
|
253799
253664
|
import { Readable as Readable4, Writable as Writable2, Duplex as Duplex2 } from "node:stream";
|
|
253800
253665
|
var handleStdioAsync = (options, verboseInfo) => handleStdio(addPropertiesAsync, options, verboseInfo, false);
|
|
@@ -253817,8 +253682,8 @@ var addProperties2 = {
|
|
|
253817
253682
|
var addPropertiesAsync = {
|
|
253818
253683
|
input: {
|
|
253819
253684
|
...addProperties2,
|
|
253820
|
-
fileUrl: ({ value }) => ({ stream:
|
|
253821
|
-
filePath: ({ value: { file: file2 } }) => ({ stream:
|
|
253685
|
+
fileUrl: ({ value }) => ({ stream: createReadStream2(value) }),
|
|
253686
|
+
filePath: ({ value: { file: file2 } }) => ({ stream: createReadStream2(file2) }),
|
|
253822
253687
|
webStream: ({ value }) => ({ stream: Readable4.fromWeb(value) }),
|
|
253823
253688
|
iterable: ({ value }) => ({ stream: Readable4.from(value) }),
|
|
253824
253689
|
asyncIterable: ({ value }) => ({ stream: Readable4.from(value) }),
|
|
@@ -258473,102 +258338,9 @@ function writeFollowLine(entry, jsonMode) {
|
|
|
258473
258338
|
process.stdout.write(`${line}
|
|
258474
258339
|
`);
|
|
258475
258340
|
}
|
|
258476
|
-
|
|
258477
|
-
|
|
258478
|
-
|
|
258479
|
-
time: event.time,
|
|
258480
|
-
level: event.level,
|
|
258481
|
-
message: event.function ? `[${event.function}] ${event.message}` : event.message,
|
|
258482
|
-
source: event.function ?? ""
|
|
258483
|
-
};
|
|
258484
|
-
}
|
|
258485
|
-
async function printStreamUntilEnd(stream, levelFilter, jsonMode, startTime) {
|
|
258486
|
-
let lastTime = startTime;
|
|
258487
|
-
let provedAlive = false;
|
|
258488
|
-
try {
|
|
258489
|
-
for await (const event of stream) {
|
|
258490
|
-
provedAlive = true;
|
|
258491
|
-
if (event.kind === "end")
|
|
258492
|
-
return { lastTime, provedAlive, end: event.end };
|
|
258493
|
-
if (event.kind === "ping")
|
|
258494
|
-
continue;
|
|
258495
|
-
if (levelFilter && event.log.level !== levelFilter)
|
|
258496
|
-
continue;
|
|
258497
|
-
writeFollowLine(streamEventToLogEntry(event.log), jsonMode);
|
|
258498
|
-
if (event.log.time > lastTime)
|
|
258499
|
-
lastTime = event.log.time;
|
|
258500
|
-
}
|
|
258501
|
-
} catch {}
|
|
258502
|
-
return { lastTime, provedAlive, end: null };
|
|
258503
|
-
}
|
|
258504
|
-
var STREAM_RECONNECT_DELAY_MS = 1000;
|
|
258505
|
-
var MAX_DROPS_SINCE_LAST_EVENT = 2;
|
|
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;
|
|
258509
|
-
async function connectWhileTransientlyUnavailable(filters) {
|
|
258510
|
-
let attempt = await openLogStream(filters);
|
|
258511
|
-
for (const retryDelay of CONNECT_RETRY_DELAYS_MS) {
|
|
258512
|
-
if (attempt.kind !== "transient")
|
|
258513
|
-
return attempt;
|
|
258514
|
-
await delay2(retryDelay);
|
|
258515
|
-
attempt = await openLogStream(filters);
|
|
258516
|
-
}
|
|
258517
|
-
return attempt;
|
|
258518
|
-
}
|
|
258519
|
-
async function streamUntilExhausted(firstStream, filters, options, jsonMode) {
|
|
258520
|
-
let events = firstStream;
|
|
258521
|
-
let lastTime = "";
|
|
258522
|
-
let dropsSinceLastEvent = 0;
|
|
258523
|
-
while (true) {
|
|
258524
|
-
const ending = await printStreamUntilEnd(events, options.level, jsonMode, lastTime);
|
|
258525
|
-
lastTime = ending.lastTime;
|
|
258526
|
-
if (ending.end) {
|
|
258527
|
-
if (!ending.end.retriable)
|
|
258528
|
-
return;
|
|
258529
|
-
dropsSinceLastEvent = 0;
|
|
258530
|
-
} else {
|
|
258531
|
-
dropsSinceLastEvent = countDropTowardGivingUp(dropsSinceLastEvent, ending.provedAlive);
|
|
258532
|
-
if (shouldGiveUpStreaming(dropsSinceLastEvent))
|
|
258533
|
-
return;
|
|
258534
|
-
}
|
|
258535
|
-
await delay2(STREAM_RECONNECT_DELAY_MS);
|
|
258536
|
-
const reopened = await connectWhileTransientlyUnavailable(filters);
|
|
258537
|
-
if (reopened.kind !== "stream")
|
|
258538
|
-
return;
|
|
258539
|
-
events = reopened.events;
|
|
258540
|
-
}
|
|
258541
|
-
}
|
|
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
|
-
]
|
|
258551
|
-
});
|
|
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
|
-
}
|
|
258569
|
-
async function pollLogs(functionNames, options, availableFunctionNames, jsonMode, initialState) {
|
|
258570
|
-
let state = initialState;
|
|
258571
|
-
let first = state.lastTime === "";
|
|
258341
|
+
async function followLogs(functionNames, options, availableFunctionNames, jsonMode) {
|
|
258342
|
+
let state = { lastTime: "", boundaryKeys: new Set };
|
|
258343
|
+
let first = true;
|
|
258572
258344
|
while (true) {
|
|
258573
258345
|
const pollOptions = first ? options : { ...options, since: state.lastTime };
|
|
258574
258346
|
const entries = await fetchLogsForFunctions(functionNames, pollOptions, availableFunctionNames);
|
|
@@ -258578,7 +258350,7 @@ async function pollLogs(functionNames, options, availableFunctionNames, jsonMode
|
|
|
258578
258350
|
for (const entry of fresh)
|
|
258579
258351
|
writeFollowLine(entry, jsonMode);
|
|
258580
258352
|
first = false;
|
|
258581
|
-
await
|
|
258353
|
+
await new Promise((resolve9) => setTimeout(resolve9, 2000));
|
|
258582
258354
|
}
|
|
258583
258355
|
}
|
|
258584
258356
|
function formatLogs(entries, env3) {
|
|
@@ -258670,9 +258442,6 @@ async function logsAction(ctx, options) {
|
|
|
258670
258442
|
return { outroMessage: "No functions found in this app." };
|
|
258671
258443
|
}
|
|
258672
258444
|
if (options.follow) {
|
|
258673
|
-
if (options.since) {
|
|
258674
|
-
throw new InvalidInputError("--since cannot be combined with --follow yet (the realtime stream starts from now).");
|
|
258675
|
-
}
|
|
258676
258445
|
if (options.until) {
|
|
258677
258446
|
throw new InvalidInputError("--until cannot be combined with --follow (a stream has no end).");
|
|
258678
258447
|
}
|
|
@@ -258680,7 +258449,7 @@ async function logsAction(ctx, options) {
|
|
|
258680
258449
|
throw new InvalidInputError("--order cannot be combined with --follow (a live tail always streams oldest to newest).");
|
|
258681
258450
|
}
|
|
258682
258451
|
options.order = "asc";
|
|
258683
|
-
return followLogs(functionNames, options, availableFunctionNames, ctx.jsonMode
|
|
258452
|
+
return followLogs(functionNames, options, availableFunctionNames, ctx.jsonMode);
|
|
258684
258453
|
}
|
|
258685
258454
|
let entries = await fetchLogsForFunctions(functionNames, options, availableFunctionNames);
|
|
258686
258455
|
const limit = options.limit ? Number.parseInt(options.limit, 10) : undefined;
|
|
@@ -258699,7 +258468,7 @@ async function logsAction(ctx, options) {
|
|
|
258699
258468
|
function getLogsCommand() {
|
|
258700
258469
|
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([
|
|
258701
258470
|
...LogLevelSchema.options
|
|
258702
|
-
])).option("-n, --limit <n>", "Results per page (1-1000
|
|
258471
|
+
])).option("-n, --limit <n>", "Results per page (1-1000, default: 50)").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);
|
|
258703
258472
|
}
|
|
258704
258473
|
|
|
258705
258474
|
// src/cli/commands/project/scaffold.ts
|
|
@@ -258902,7 +258671,7 @@ async function callTool(appId, tool, payload, schema12, context, timeout2 = 6000
|
|
|
258902
258671
|
function listDirectory(appId, params) {
|
|
258903
258672
|
return callTool(appId, "list_directory", { ...params }, ListDirectoryResponseSchema, "listing directory");
|
|
258904
258673
|
}
|
|
258905
|
-
function
|
|
258674
|
+
function readFile4(appId, params) {
|
|
258906
258675
|
return callTool(appId, "read_file", { ...params }, ReadFileResponseSchema, "reading file");
|
|
258907
258676
|
}
|
|
258908
258677
|
function writeFile2(appId, params) {
|
|
@@ -259032,7 +258801,7 @@ async function readFileAction({ runTask: runTask2 }, paths, options) {
|
|
|
259032
258801
|
const { id: appId } = getAppContext();
|
|
259033
258802
|
const offset = parsePositiveInt(options.offset, "--offset");
|
|
259034
258803
|
const limit = parsePositiveInt(options.limit, "--limit");
|
|
259035
|
-
const result = await runTask2("Reading file", () =>
|
|
258804
|
+
const result = await runTask2("Reading file", () => readFile4(appId, { paths, offset, limit }));
|
|
259036
258805
|
return { outroMessage: "Read file", stdout: toJsonStdout(result) };
|
|
259037
258806
|
}
|
|
259038
258807
|
function getSandboxReadFileCommand() {
|
|
@@ -266334,7 +266103,7 @@ class ReduceableCache {
|
|
|
266334
266103
|
}
|
|
266335
266104
|
}
|
|
266336
266105
|
// ../../node_modules/posthog-node/dist/extensions/error-tracking/modifiers/context-lines.node.mjs
|
|
266337
|
-
import { createReadStream as
|
|
266106
|
+
import { createReadStream as createReadStream3 } from "node:fs";
|
|
266338
266107
|
import { createInterface as createInterface2 } from "node:readline";
|
|
266339
266108
|
var LRU_FILE_CONTENTS_CACHE = new exports_error_tracking.ReduceableCache(25);
|
|
266340
266109
|
var LRU_FILE_CONTENTS_FS_READ_FAILED = new exports_error_tracking.ReduceableCache(20);
|
|
@@ -266378,7 +266147,7 @@ async function addSourceContext(frames) {
|
|
|
266378
266147
|
}
|
|
266379
266148
|
function getContextLinesFromFile(path19, ranges, output) {
|
|
266380
266149
|
return new Promise((resolve16) => {
|
|
266381
|
-
const stream =
|
|
266150
|
+
const stream = createReadStream3(path19);
|
|
266382
266151
|
const lineReaded = createInterface2({
|
|
266383
266152
|
input: stream
|
|
266384
266153
|
});
|
|
@@ -268329,4 +268098,4 @@ export {
|
|
|
268329
268098
|
runCLI
|
|
268330
268099
|
};
|
|
268331
268100
|
|
|
268332
|
-
//# debugId=
|
|
268101
|
+
//# debugId=31021F5DECFABABC64756E2164756E21
|