@base44-preview/cli 0.0.56-pr.551.d02ef77 → 0.0.56-pr.551.d451628

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 CHANGED
@@ -253520,8 +253520,12 @@ function formatEntry(entry) {
253520
253520
  const message = entry.message.trim();
253521
253521
  return `${time3} ${level} ${message}`;
253522
253522
  }
253523
- function formatLogs(entries) {
253523
+ function formatLogs(entries, env3) {
253524
253524
  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
+ }
253525
253529
  return `No logs found matching the filters.
253526
253530
  `;
253527
253531
  }
@@ -253558,24 +253562,17 @@ async function fetchLogsForFunction(functionName, filters, availableFunctionName
253558
253562
  }
253559
253563
  }
253560
253564
  async function fetchLogsForFunctions(functionNames, options, availableFunctionNames) {
253561
- const env3 = options.env ?? "all";
253562
- const envs = env3 === "all" ? ["preview", "prod"] : [env3];
253565
+ const filters = parseFunctionFilters(options);
253563
253566
  const allEntries = [];
253564
253567
  for (const functionName of functionNames) {
253565
- const logsPerEnv = await Promise.all(envs.map((e2) => fetchLogsForFunction(functionName, { ...parseFunctionFilters(options), env: e2 }, availableFunctionNames)));
253566
- const entries = logsPerEnv.flat().map((entry) => normalizeLogEntry(entry, functionName));
253567
- allEntries.push(...entries);
253568
+ const logs = await fetchLogsForFunction(functionName, filters, availableFunctionNames);
253569
+ allEntries.push(...logs.map((entry) => normalizeLogEntry(entry, functionName)));
253568
253570
  }
253569
- const order = options.order?.toUpperCase() === "ASC" ? 1 : -1;
253570
- allEntries.sort((a2, b) => order * a2.time.localeCompare(b.time));
253571
- const seen = new Set;
253572
- return allEntries.filter((e2) => {
253573
- const key = `${e2.time}|${e2.source}|${e2.message}`;
253574
- if (seen.has(key))
253575
- return false;
253576
- seen.add(key);
253577
- return true;
253578
- });
253571
+ if (functionNames.length > 1) {
253572
+ const order = options.order?.toUpperCase() === "ASC" ? 1 : -1;
253573
+ allEntries.sort((a2, b) => order * a2.time.localeCompare(b.time));
253574
+ }
253575
+ return allEntries;
253579
253576
  }
253580
253577
  async function getProjectFunctionNames(projectRoot) {
253581
253578
  const { functions } = await readProjectConfig(projectRoot);
@@ -253609,12 +253606,13 @@ async function logsAction(ctx, options) {
253609
253606
  if (limit !== undefined && entries.length > limit) {
253610
253607
  entries = entries.slice(0, limit);
253611
253608
  }
253609
+ const env3 = options.env ?? "preview";
253612
253610
  const logsOutput = options.json ? `${JSON.stringify(entries, null, 2)}
253613
- ` : formatLogs(entries);
253611
+ ` : formatLogs(entries, env3);
253614
253612
  return { outroMessage: "Fetched logs", stdout: logsOutput };
253615
253613
  }
253616
253614
  function getLogsCommand() {
253617
- 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 format)", normalizeDatetime).option("--until <datetime>", "Show logs until this time (ISO format)", 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("--env <env>", "Filter by environment").choices(["preview", "prod", "all"]).default("all")).action(logsAction);
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 (ISO format)", normalizeDatetime).option("--until <datetime>", "Show logs until this time (ISO format)", 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("--env <env>", "Environment to fetch logs from (default: preview)").choices(["preview", "prod"])).action(logsAction);
253618
253616
  }
253619
253617
 
253620
253618
  // src/cli/commands/project/scaffold.ts
@@ -261990,4 +261988,4 @@ export {
261990
261988
  CLIExitError
261991
261989
  };
261992
261990
 
261993
- //# debugId=62D8AD80DEE0720E64756E2164756E21
261991
+ //# debugId=2288207DAC9F5A5264756E2164756E21