@karakeep/cli 0.29.0 → 0.29.1

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.mjs +69 -4
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
- import * as require$$3 from "node:fs";
3
- import require$$3__default from "node:fs";
4
2
  import process$1, { stdout, stdin } from "node:process";
5
3
  import os from "node:os";
6
4
  import tty from "node:tty";
7
5
  import require$$0 from "node:events";
8
6
  import require$$1, { spawn } from "node:child_process";
9
7
  import path from "node:path";
8
+ import * as require$$3 from "node:fs";
9
+ import require$$3__default from "node:fs";
10
10
  import fsp from "node:fs/promises";
11
11
  import readline from "node:readline/promises";
12
12
  let globalOpts = void 0;
@@ -11216,6 +11216,70 @@ function requireSrc() {
11216
11216
  return src;
11217
11217
  }
11218
11218
  var srcExports = /* @__PURE__ */ requireSrc();
11219
+ const adminCmd = new Command().name("admin").description("admin commands");
11220
+ function toHumanReadableSize(size) {
11221
+ const sizes = ["Bytes", "KB", "MB", "GB", "TB"];
11222
+ if (size === 0) return "0 Bytes";
11223
+ const i = Math.floor(Math.log(size) / Math.log(1024));
11224
+ return (size / Math.pow(1024, i)).toFixed(2) + " " + sizes[i];
11225
+ }
11226
+ const usersCmd = new Command().name("users").description("user management commands");
11227
+ usersCmd.command("list").description("list all users").action(async () => {
11228
+ const api2 = getAPIClient();
11229
+ try {
11230
+ const [usersResp, userStats] = await Promise.all([
11231
+ api2.users.list.query(),
11232
+ api2.admin.userStats.query()
11233
+ ]);
11234
+ if (getGlobalOptions().json) {
11235
+ printObject({
11236
+ users: usersResp.users.map((u) => ({
11237
+ ...u,
11238
+ numBookmarks: userStats[u.id]?.numBookmarks ?? 0,
11239
+ assetSizes: userStats[u.id]?.assetSizes ?? 0
11240
+ }))
11241
+ });
11242
+ } else {
11243
+ const data = [
11244
+ [
11245
+ "Name",
11246
+ "Email",
11247
+ "Num Bookmarks",
11248
+ "Asset Sizes",
11249
+ "Role",
11250
+ "Local User"
11251
+ ]
11252
+ ];
11253
+ usersResp.users.forEach((user) => {
11254
+ const stats = userStats[user.id] ?? {
11255
+ numBookmarks: 0,
11256
+ assetSizes: 0
11257
+ };
11258
+ const numBookmarksDisplay = `${stats.numBookmarks} / ${user.bookmarkQuota?.toString() ?? "Unlimited"}`;
11259
+ const assetSizesDisplay = `${toHumanReadableSize(stats.assetSizes)} / ${user.storageQuota ? toHumanReadableSize(user.storageQuota) : "Unlimited"}`;
11260
+ data.push([
11261
+ user.name,
11262
+ user.email,
11263
+ numBookmarksDisplay,
11264
+ assetSizesDisplay,
11265
+ user.role ?? "",
11266
+ user.localUser ? "✓" : "✗"
11267
+ ]);
11268
+ });
11269
+ console.log(
11270
+ srcExports.table(data, {
11271
+ border: srcExports.getBorderCharacters("ramac"),
11272
+ drawHorizontalLine: (lineIndex, rowCount) => {
11273
+ return lineIndex === 0 || lineIndex === 1 || lineIndex === rowCount;
11274
+ }
11275
+ })
11276
+ );
11277
+ }
11278
+ } catch (error2) {
11279
+ printErrorMessageWithReason("Failed to list all users", error2);
11280
+ }
11281
+ });
11282
+ adminCmd.addCommand(usersCmd);
11219
11283
  function listsToTree(lists) {
11220
11284
  const idToList = lists.reduce((acc, list) => {
11221
11285
  acc[list.id] = list;
@@ -17237,7 +17301,7 @@ async function wipeTags(api2) {
17237
17301
  throw error2;
17238
17302
  }
17239
17303
  }
17240
- const __vite_import_meta_env__ = { "BASE_URL": "/", "CLI_VERSION": "0.29.0", "DEV": false, "MODE": "production", "PROD": true, "SSR": true };
17304
+ const __vite_import_meta_env__ = { "BASE_URL": "/", "CLI_VERSION": "0.29.1", "DEV": false, "MODE": "production", "PROD": true, "SSR": true };
17241
17305
  const program = new Command().name("karakeep").description("A CLI interface to interact with the karakeep api").addOption(
17242
17306
  new Option("--api-key <key>", "the API key to interact with the API").makeOptionMandatory(true).env("KARAKEEP_API_KEY")
17243
17307
  ).addOption(
@@ -17246,8 +17310,9 @@ const program = new Command().name("karakeep").description("A CLI interface to i
17246
17310
  "the address of the server to connect to"
17247
17311
  ).makeOptionMandatory(true).env("KARAKEEP_SERVER_ADDR")
17248
17312
  ).addOption(new Option("--json", "to output the result as JSON")).version(
17249
- __vite_import_meta_env__ && "CLI_VERSION" in __vite_import_meta_env__ ? "0.29.0" : "0.0.0"
17313
+ __vite_import_meta_env__ && "CLI_VERSION" in __vite_import_meta_env__ ? "0.29.1" : "0.0.0"
17250
17314
  );
17315
+ program.addCommand(adminCmd);
17251
17316
  program.addCommand(bookmarkCmd);
17252
17317
  program.addCommand(listsCmd);
17253
17318
  program.addCommand(tagsCmd);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package.json",
3
3
  "name": "@karakeep/cli",
4
- "version": "0.29.0",
4
+ "version": "0.29.1",
5
5
  "description": "Command Line Interface (CLI) for Karakeep",
6
6
  "license": "GNU Affero General Public License version 3",
7
7
  "type": "module",