@base44-preview/cli 0.0.56-pr.551.d451628 → 0.0.56-pr.552.e304fb7
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 +40 -39
- package/dist/cli/index.js.map +6 -6
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -243426,7 +243426,7 @@ var ListFunctionsResponseSchema = exports_external.object({
|
|
|
243426
243426
|
var LogLevelSchema = exports_external.enum(["info", "warning", "error", "debug"]);
|
|
243427
243427
|
var FunctionLogEntrySchema = exports_external.object({
|
|
243428
243428
|
time: exports_external.string(),
|
|
243429
|
-
level: LogLevelSchema,
|
|
243429
|
+
level: exports_external.preprocess((v) => v === "warn" ? "warning" : !v || v === "log" ? "info" : v, LogLevelSchema),
|
|
243430
243430
|
message: exports_external.string()
|
|
243431
243431
|
});
|
|
243432
243432
|
var FunctionLogsResponseSchema = exports_external.array(FunctionLogEntrySchema);
|
|
@@ -243487,9 +243487,6 @@ function buildLogsQueryString(filters) {
|
|
|
243487
243487
|
if (filters.order) {
|
|
243488
243488
|
params.set("order", filters.order);
|
|
243489
243489
|
}
|
|
243490
|
-
if (filters.env) {
|
|
243491
|
-
params.set("env", filters.env);
|
|
243492
|
-
}
|
|
243493
243490
|
return params;
|
|
243494
243491
|
}
|
|
243495
243492
|
async function fetchFunctionLogs(functionName, filters = {}) {
|
|
@@ -251109,9 +251106,12 @@ class Base44Command extends Command {
|
|
|
251109
251106
|
}
|
|
251110
251107
|
return this._context;
|
|
251111
251108
|
}
|
|
251109
|
+
isRawOutputMode() {
|
|
251110
|
+
return this.opts().format === "json";
|
|
251111
|
+
}
|
|
251112
251112
|
action(fn) {
|
|
251113
251113
|
return super.action(async (...args) => {
|
|
251114
|
-
const quiet = this.context.isNonInteractive;
|
|
251114
|
+
const quiet = this.context.isNonInteractive || this.isRawOutputMode();
|
|
251115
251115
|
if (!quiet) {
|
|
251116
251116
|
await showCommandStart(this._commandOptions.fullBanner);
|
|
251117
251117
|
}
|
|
@@ -253499,9 +253499,6 @@ function parseFunctionFilters(options) {
|
|
|
253499
253499
|
if (options.order) {
|
|
253500
253500
|
filters.order = options.order.toLowerCase();
|
|
253501
253501
|
}
|
|
253502
|
-
if (options.env) {
|
|
253503
|
-
filters.env = options.env;
|
|
253504
|
-
}
|
|
253505
253502
|
return filters;
|
|
253506
253503
|
}
|
|
253507
253504
|
function parseFunctionNames(option) {
|
|
@@ -253510,6 +253507,11 @@ function parseFunctionNames(option) {
|
|
|
253510
253507
|
return option.split(",").map((s) => s.trim()).filter((s) => s.length > 0);
|
|
253511
253508
|
}
|
|
253512
253509
|
function normalizeDatetime(value) {
|
|
253510
|
+
const rel = value.match(/^(\d+)(m|h|d)$/);
|
|
253511
|
+
if (rel) {
|
|
253512
|
+
const ms = rel[2] === "m" ? Number(rel[1]) * 60000 : rel[2] === "h" ? Number(rel[1]) * 3600000 : Number(rel[1]) * 86400000;
|
|
253513
|
+
return new Date(Date.now() - ms).toISOString();
|
|
253514
|
+
}
|
|
253513
253515
|
if (/Z$|[+-]\d{2}:\d{2}$/.test(value))
|
|
253514
253516
|
return value;
|
|
253515
253517
|
return `${value}Z`;
|
|
@@ -253520,12 +253522,8 @@ function formatEntry(entry) {
|
|
|
253520
253522
|
const message = entry.message.trim();
|
|
253521
253523
|
return `${time3} ${level} ${message}`;
|
|
253522
253524
|
}
|
|
253523
|
-
function formatLogs(entries
|
|
253525
|
+
function formatLogs(entries) {
|
|
253524
253526
|
if (entries.length === 0) {
|
|
253525
|
-
if (env3 === "prod") {
|
|
253526
|
-
return `No production logs found. Has this app been published? Try --env preview to see draft logs.
|
|
253527
|
-
`;
|
|
253528
|
-
}
|
|
253529
253527
|
return `No logs found matching the filters.
|
|
253530
253528
|
`;
|
|
253531
253529
|
}
|
|
@@ -253542,30 +253540,30 @@ function normalizeLogEntry(entry, functionName) {
|
|
|
253542
253540
|
source: functionName
|
|
253543
253541
|
};
|
|
253544
253542
|
}
|
|
253545
|
-
async function fetchLogsForFunction(functionName, filters, availableFunctionNames) {
|
|
253546
|
-
try {
|
|
253547
|
-
return await fetchFunctionLogs(functionName, filters);
|
|
253548
|
-
} catch (error48) {
|
|
253549
|
-
if (error48 instanceof ApiError && error48.statusCode === 404 && availableFunctionNames.length > 0) {
|
|
253550
|
-
const available = availableFunctionNames.join(", ");
|
|
253551
|
-
throw new InvalidInputError(`Function "${functionName}" was not found in this app`, {
|
|
253552
|
-
hints: [
|
|
253553
|
-
{ message: `Available functions in this project: ${available}` },
|
|
253554
|
-
{
|
|
253555
|
-
message: "Make sure the function has been deployed before fetching logs",
|
|
253556
|
-
command: "base44 functions deploy"
|
|
253557
|
-
}
|
|
253558
|
-
]
|
|
253559
|
-
});
|
|
253560
|
-
}
|
|
253561
|
-
throw error48;
|
|
253562
|
-
}
|
|
253563
|
-
}
|
|
253564
253543
|
async function fetchLogsForFunctions(functionNames, options, availableFunctionNames) {
|
|
253565
253544
|
const filters = parseFunctionFilters(options);
|
|
253566
253545
|
const allEntries = [];
|
|
253567
253546
|
for (const functionName of functionNames) {
|
|
253568
|
-
|
|
253547
|
+
let logs;
|
|
253548
|
+
try {
|
|
253549
|
+
logs = await fetchFunctionLogs(functionName, filters);
|
|
253550
|
+
} catch (error48) {
|
|
253551
|
+
if (error48 instanceof ApiError && error48.statusCode === 404 && availableFunctionNames.length > 0) {
|
|
253552
|
+
const available = availableFunctionNames.join(", ");
|
|
253553
|
+
throw new InvalidInputError(`Function "${functionName}" was not found in this app`, {
|
|
253554
|
+
hints: [
|
|
253555
|
+
{
|
|
253556
|
+
message: `Available functions in this project: ${available}`
|
|
253557
|
+
},
|
|
253558
|
+
{
|
|
253559
|
+
message: "Make sure the function has been deployed before fetching logs",
|
|
253560
|
+
command: "base44 functions deploy"
|
|
253561
|
+
}
|
|
253562
|
+
]
|
|
253563
|
+
});
|
|
253564
|
+
}
|
|
253565
|
+
throw error48;
|
|
253566
|
+
}
|
|
253569
253567
|
allEntries.push(...logs.map((entry) => normalizeLogEntry(entry, functionName)));
|
|
253570
253568
|
}
|
|
253571
253569
|
if (functionNames.length > 1) {
|
|
@@ -253606,13 +253604,16 @@ async function logsAction(ctx, options) {
|
|
|
253606
253604
|
if (limit !== undefined && entries.length > limit) {
|
|
253607
253605
|
entries = entries.slice(0, limit);
|
|
253608
253606
|
}
|
|
253609
|
-
const
|
|
253610
|
-
|
|
253611
|
-
|
|
253612
|
-
return {
|
|
253607
|
+
const logsOutput = options.format === "json" ? `${JSON.stringify(entries, null, 2)}
|
|
253608
|
+
` : formatLogs(entries);
|
|
253609
|
+
const shouldOutputOutroMessage = options.format !== "json";
|
|
253610
|
+
return {
|
|
253611
|
+
outroMessage: shouldOutputOutroMessage ? "Fetched logs" : undefined,
|
|
253612
|
+
stdout: logsOutput
|
|
253613
|
+
};
|
|
253613
253614
|
}
|
|
253614
253615
|
function getLogsCommand() {
|
|
253615
|
-
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 project functions").option("--since <datetime>", "Show logs from this time
|
|
253616
|
+
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 project 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([...LogLevelSchema.options]).hideHelp()).option("-n, --limit <n>", "Results per page (1-1000, default: 50)").addOption(new Option("--order <order>", "Sort order").choices(["asc", "desc"])).addOption(new Option("--format <format>", "Output format (json produces clean stdout for piping to jq)").choices(["text", "json"]).default("text")).action(logsAction);
|
|
253616
253617
|
}
|
|
253617
253618
|
|
|
253618
253619
|
// src/cli/commands/project/scaffold.ts
|
|
@@ -261988,4 +261989,4 @@ export {
|
|
|
261988
261989
|
CLIExitError
|
|
261989
261990
|
};
|
|
261990
261991
|
|
|
261991
|
-
//# debugId=
|
|
261992
|
+
//# debugId=F613860C84D1043764756E2164756E21
|