@pmate/cli 0.20.5 → 0.20.7

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.
Files changed (2) hide show
  1. package/dist/index.js +8 -6
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -20118,7 +20118,7 @@ var ServiceRuntimeRunner = class {
20118
20118
  });
20119
20119
  ui.title(`Logs for ${namespace}/${appName}`);
20120
20120
  ui.info("Source", { mode: options.history ? "history" : "online" });
20121
- this.renderPage(page);
20121
+ this.renderPage(page, { oldestFirst: Boolean(options.follow) });
20122
20122
  if (options.follow) {
20123
20123
  await this.followLogs(namespace, appName, {
20124
20124
  page: options.page ?? 0,
@@ -20424,14 +20424,15 @@ var ServiceRuntimeRunner = class {
20424
20424
  async fetchLogPage(namespace, appName, options) {
20425
20425
  const baseUrl = (process.env.INDEXER_BASE_URL || "https://indexer.pmate.chat").replace(/\/$/, "");
20426
20426
  const chainId = process.env.BLOCKCHAIN_CHAIN_ID || "pmate";
20427
- const action = options.history ? "list" : "search";
20427
+ const hasSearch = Boolean(options.search?.trim());
20428
+ const action = options.history || !hasSearch ? "list" : "search";
20428
20429
  const url = new URL(
20429
20430
  `/chains/${encodeURIComponent(chainId)}/namespaces/${encodeURIComponent(namespace)}/log/${encodeURIComponent(appName)}/${action}`,
20430
20431
  `${baseUrl}/`
20431
20432
  );
20432
20433
  url.searchParams.set("page_id", String(options.page));
20433
- if (options.search && !options.history) {
20434
- url.searchParams.set("keyword", options.search);
20434
+ if (hasSearch && !options.history) {
20435
+ url.searchParams.set("keyword", options.search.trim());
20435
20436
  }
20436
20437
  const response = await fetch(url.toString(), {
20437
20438
  method: "GET",
@@ -20451,14 +20452,15 @@ var ServiceRuntimeRunner = class {
20451
20452
  }
20452
20453
  return payload.data;
20453
20454
  }
20454
- renderPage(page) {
20455
+ renderPage(page, options = {}) {
20455
20456
  ui.info("Page", {
20456
20457
  page: page.page,
20457
20458
  totalPage: page.totalPage,
20458
20459
  pageSize: page.pageSize,
20459
20460
  items: page.data.length
20460
20461
  });
20461
- for (const item of page.data) {
20462
+ const items = options.oldestFirst ? [...page.data].reverse() : page.data;
20463
+ for (const item of items) {
20462
20464
  ui.plain(this.renderLogLine(item));
20463
20465
  }
20464
20466
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pmate/cli",
3
- "version": "0.20.5",
3
+ "version": "0.20.7",
4
4
  "description": "CLI utilities for the pMate project",
5
5
  "license": "MIT",
6
6
  "bin": {