kafka-console 1.3.52 → 1.4.0

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/README.md CHANGED
@@ -171,7 +171,7 @@ export interface Formatter<T> {
171
171
 
172
172
  ## License
173
173
  License [The MIT License](http://opensource.org/licenses/MIT)
174
- Copyright (c) 2023 Ivan Zakharchanka
174
+ Copyright (c) 2024 Ivan Zakharchanka
175
175
 
176
176
  [npm-url]: https://www.npmjs.com/package/kafka-console
177
177
  [downloads-image]: https://img.shields.io/npm/dw/kafka-console.svg?maxAge=43200
package/build/cli.js CHANGED
File without changes
@@ -23,7 +23,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  const kafka_1 = require("../utils/kafka");
24
24
  function config(opts_1, _a) {
25
25
  return __awaiter(this, arguments, void 0, function* (opts, { parent }) {
26
- const _b = Object.assign(Object.assign({}, parent.opts()), opts), { resource, resourceName: name, brokers, logLevel, ssl } = _b, rest = __rest(_b, ["resource", "resourceName", "brokers", "logLevel", "ssl"]);
26
+ const _b = Object.assign(Object.assign({}, parent.opts()), opts), { resource, resourceName: name, brokers, logLevel, ssl, pretty } = _b, rest = __rest(_b, ["resource", "resourceName", "brokers", "logLevel", "ssl", "pretty"]);
27
+ const space = pretty ? 2 : 0;
27
28
  const sasl = (0, kafka_1.getSASL)(rest);
28
29
  const client = (0, kafka_1.createClient)(brokers, ssl, sasl, logLevel);
29
30
  const admin = yield (0, kafka_1.createAdmin)(client);
@@ -37,7 +38,7 @@ function config(opts_1, _a) {
37
38
  ],
38
39
  });
39
40
  for (let resource of resources) {
40
- console.log(resource);
41
+ console.log(JSON.stringify(resource, null, space));
41
42
  }
42
43
  yield admin.disconnect();
43
44
  });
@@ -23,14 +23,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  const kafka_1 = require("../utils/kafka");
24
24
  function createTopic(topic_1, opts_1, _a) {
25
25
  return __awaiter(this, arguments, void 0, function* (topic, opts, { parent }) {
26
- const _b = Object.assign(Object.assign({}, parent.opts()), opts), { brokers, logLevel, ssl } = _b, rest = __rest(_b, ["brokers", "logLevel", "ssl"]);
26
+ const _b = Object.assign(Object.assign({}, parent.opts()), opts), { brokers, logLevel, ssl, pretty } = _b, rest = __rest(_b, ["brokers", "logLevel", "ssl", "pretty"]);
27
27
  const sasl = (0, kafka_1.getSASL)(rest);
28
28
  const client = (0, kafka_1.createClient)(brokers, ssl, sasl, logLevel);
29
29
  const admin = yield (0, kafka_1.createAdmin)(client);
30
30
  const topics = yield admin.createTopics({
31
31
  topics: [{ topic }],
32
32
  });
33
- console.log(topics);
33
+ const space = pretty ? 2 : 0;
34
+ console.log(JSON.stringify(topics, null, space));
34
35
  yield admin.disconnect();
35
36
  });
36
37
  }
@@ -23,7 +23,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  const kafka_1 = require("../utils/kafka");
24
24
  function fetchTopicOffset(topic_1, timestamp_1, opts_1, _a) {
25
25
  return __awaiter(this, arguments, void 0, function* (topic, timestamp, opts, { parent }) {
26
- const _b = Object.assign(Object.assign({}, parent.opts()), opts), { brokers, logLevel, ssl } = _b, rest = __rest(_b, ["brokers", "logLevel", "ssl"]);
26
+ const _b = Object.assign(Object.assign({}, parent.opts()), opts), { brokers, logLevel, ssl, pretty } = _b, rest = __rest(_b, ["brokers", "logLevel", "ssl", "pretty"]);
27
+ const space = pretty ? 2 : 0;
27
28
  const sasl = (0, kafka_1.getSASL)(rest);
28
29
  const client = (0, kafka_1.createClient)(brokers, ssl, sasl, logLevel);
29
30
  const admin = yield (0, kafka_1.createAdmin)(client);
@@ -33,11 +34,11 @@ function fetchTopicOffset(topic_1, timestamp_1, opts_1, _a) {
33
34
  throw new Error(`Invalid timestamp "${timestamp}"`);
34
35
  }
35
36
  const topicOffsets = yield admin.fetchTopicOffsetsByTimestamp(topic, unixTimestamp);
36
- console.log(topicOffsets);
37
+ console.log(JSON.stringify(topicOffsets, null, space));
37
38
  }
38
39
  else {
39
40
  const topicOffsets = yield admin.fetchTopicOffsets(topic);
40
- console.log(topicOffsets);
41
+ console.log(JSON.stringify(topicOffsets, null, space));
41
42
  }
42
43
  yield admin.disconnect();
43
44
  });
@@ -23,16 +23,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  const kafka_1 = require("../utils/kafka");
24
24
  function list(opts_1, _a) {
25
25
  return __awaiter(this, arguments, void 0, function* (opts, { parent }) {
26
- const _b = Object.assign(Object.assign({}, parent.opts()), opts), { all, brokers, logLevel, ssl } = _b, rest = __rest(_b, ["all", "brokers", "logLevel", "ssl"]);
26
+ const _b = Object.assign(Object.assign({}, parent.opts()), opts), { all, brokers, logLevel, ssl, pretty } = _b, rest = __rest(_b, ["all", "brokers", "logLevel", "ssl", "pretty"]);
27
27
  const sasl = (0, kafka_1.getSASL)(rest);
28
28
  const client = (0, kafka_1.createClient)(brokers, ssl, sasl, logLevel);
29
29
  const cluster = yield (0, kafka_1.createCluster)(client);
30
30
  const topics = (yield cluster.metadata()).topicMetadata
31
31
  .filter(topic => all || !topic.isInternal)
32
32
  .map(({ topic }) => topic);
33
- for (const topic of topics) {
34
- console.log(topic);
35
- }
33
+ const space = pretty ? 2 : 0;
34
+ console.log(JSON.stringify(topics, null, space));
36
35
  yield cluster.disconnect();
37
36
  });
38
37
  }
@@ -23,12 +23,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
23
23
  const kafka_1 = require("../utils/kafka");
24
24
  function metadata(opts_1, _a) {
25
25
  return __awaiter(this, arguments, void 0, function* (opts, { parent }) {
26
- const _b = Object.assign(Object.assign({}, parent.opts()), opts), { brokers, logLevel, ssl } = _b, rest = __rest(_b, ["brokers", "logLevel", "ssl"]);
26
+ const _b = Object.assign(Object.assign({}, parent.opts()), opts), { brokers, logLevel, ssl, pretty } = _b, rest = __rest(_b, ["brokers", "logLevel", "ssl", "pretty"]);
27
27
  const sasl = (0, kafka_1.getSASL)(rest);
28
28
  const client = (0, kafka_1.createClient)(brokers, ssl, sasl, logLevel);
29
29
  const cluster = yield (0, kafka_1.createCluster)(client);
30
30
  const metadata = yield cluster.metadata();
31
- console.log(JSON.stringify(metadata, null, ' '));
31
+ const space = pretty ? 2 : 0;
32
+ console.log(JSON.stringify(metadata, null, space));
32
33
  yield cluster.disconnect();
33
34
  });
34
35
  }
package/package.json CHANGED
@@ -1,18 +1,12 @@
1
1
  {
2
2
  "name": "kafka-console",
3
- "version": "1.3.52",
3
+ "version": "1.4.0",
4
4
  "description": "Kafka CLI tool",
5
5
  "main": "index.js",
6
6
  "bin": {
7
7
  "kcli": "build/cli.js",
8
8
  "kafka-console": "build/cli.js"
9
9
  },
10
- "scripts": {
11
- "build": "rm -rf build && tsc",
12
- "test": "NODE_ENV=test jest",
13
- "test:cov": "COVERAGE=1 NODE_ENV=test jest",
14
- "kcli": "ts-node src/index.ts"
15
- },
16
10
  "repository": {
17
11
  "type": "git",
18
12
  "url": "git+https://github.com/3axap4eHko/kafka-console.git"
@@ -32,20 +26,24 @@
32
26
  },
33
27
  "homepage": "https://github.com/3axap4eHko/kafka-console#readme",
34
28
  "devDependencies": {
35
- "@types/commander": "^2.12.2",
36
- "@types/jest": "^29.5.0",
37
- "@types/js-yaml": "^4.0.5",
38
- "@types/node": "^18.15.3",
39
- "@types/winston": "^2.4.4",
40
- "dotenv": "^16.0.3",
41
- "jest": "^29.5.0",
42
- "ts-jest": "^29.0.5",
43
- "ts-node": "^10.9.1",
44
- "typescript": "^5.0.2"
29
+ "@types/jest": "^29.5.12",
30
+ "@types/js-yaml": "^4.0.9",
31
+ "@types/node": "^20.11.30",
32
+ "dotenv": "^16.4.5",
33
+ "jest": "^29.7.0",
34
+ "ts-jest": "^29.1.2",
35
+ "ts-node": "^10.9.2",
36
+ "typescript": "^5.4.3"
45
37
  },
46
38
  "dependencies": {
47
- "commander": "^10.0.0",
48
- "evnty": "^0.9.0",
39
+ "commander": "^12.0.0",
40
+ "evnty": "^2.1.90",
49
41
  "kafkajs": "^2.2.4"
42
+ },
43
+ "scripts": {
44
+ "build": "rm -rf build && tsc",
45
+ "test": "NODE_ENV=test jest",
46
+ "test:cov": "COVERAGE=1 NODE_ENV=test jest",
47
+ "kcli": "ts-node src/index.ts"
50
48
  }
51
- }
49
+ }