@streamr/cli-tools 103.1.2-rc.0 → 103.2.0-experiment.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/dist/bin/streamr-internal-node-info.js +1 -1
- package/dist/bin/streamr-internal-node-info.js.map +1 -1
- package/dist/bin/streamr-stream-publish.js +72 -17
- package/dist/bin/streamr-stream-publish.js.map +1 -1
- package/dist/bin/streamr-stream-subscribe.js +31 -11
- package/dist/bin/streamr-stream-subscribe.js.map +1 -1
- package/dist/package.json +11 -11
- package/package.json +11 -11
|
@@ -9,7 +9,7 @@ const dht_1 = require("@streamr/dht");
|
|
|
9
9
|
const utils_1 = require("@streamr/utils");
|
|
10
10
|
const command_1 = require("../src/command");
|
|
11
11
|
const semver_1 = __importDefault(require("semver"));
|
|
12
|
-
const logger = new utils_1.Logger(
|
|
12
|
+
const logger = new utils_1.Logger('streamr-internal-node-info');
|
|
13
13
|
const toNormalizeNodeInfo = (info) => {
|
|
14
14
|
const isLegacyFormat = semver_1.default.satisfies(semver_1.default.coerce(info.applicationVersion), '< 102.0.0');
|
|
15
15
|
return {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamr-internal-node-info.js","sourceRoot":"","sources":["../../bin/streamr-internal-node-info.ts"],"names":[],"mappings":";;;;;;AACA,2BAAwB;AAExB,sCAA8E;AAG9E,0CAAqE;AACrE,4CAAoD;AACpD,oDAA2B;AAE3B,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"streamr-internal-node-info.js","sourceRoot":"","sources":["../../bin/streamr-internal-node-info.ts"],"names":[],"mappings":";;;;;;AACA,2BAAwB;AAExB,sCAA8E;AAG9E,0CAAqE;AACrE,4CAAoD;AACpD,oDAA2B;AAE3B,MAAM,MAAM,GAAG,IAAI,cAAM,CAAC,4BAA4B,CAAC,CAAA;AAOvD,MAAM,mBAAmB,GAAG,CAAC,IAAc,EAAsB,EAAE;IA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e,CAAC,IAAI,CAAC,CAAC,EAAE,EAAE,EAAE,CAAC,IAAA,kBAAY,EAAC,EAAE,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC,CAAA;IACvF,IAAI,cAAc,KAAK,SAAS,EAAE,CAAC;QAC/B,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,CAAA;QAClE,MAAM,cAAc,GAAG,mBAAmB,CAAC,IAAI,CAAC,CAAA;QAChD,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,oBAAoB,CAAC,cAAc,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,CAAA;IACpF,CAAC;SAAM,CAAC;QACJ,MAAM,CAAC,KAAK,CAAC,0BAA0B,CAAC,CAAA;IAC5C,CAAC;AACL,CAAC,CAAC;KACG,WAAW,CAAC,wCAAwC,CAAC;KACrD,SAAS,CAAC,QAAQ,CAAC;KACnB,UAAU,EAAE,CAAA"}
|
|
@@ -5,30 +5,57 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
require("../src/logLevel");
|
|
8
|
-
const
|
|
8
|
+
const sdk_1 = require("@streamr/sdk");
|
|
9
9
|
const utils_1 = require("@streamr/utils");
|
|
10
10
|
const event_stream_1 = __importDefault(require("event-stream"));
|
|
11
|
+
const stream_1 = require("stream");
|
|
11
12
|
const command_1 = require("../src/command");
|
|
13
|
+
const common_1 = require("../src/common");
|
|
12
14
|
const isHexadecimal = (str) => {
|
|
13
15
|
return /^[0-9a-fA-F]+$/.test(str);
|
|
14
16
|
};
|
|
15
|
-
const publishStream = (
|
|
17
|
+
const publishStream = async (streamId, partition, partitionKeyField, raw, withMetadata, binary, client) => {
|
|
18
|
+
const fullStreamId = (0, utils_1.toStreamID)(streamId, (0, utils_1.toEthereumAddress)(await client.getAddress()));
|
|
16
19
|
const writable = new stream_1.Writable({
|
|
17
20
|
objectMode: true,
|
|
18
21
|
write: (data, _, done) => {
|
|
19
|
-
let
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
22
|
+
let content;
|
|
23
|
+
let metadata;
|
|
24
|
+
let streamMessage = undefined;
|
|
25
|
+
if (binary) {
|
|
26
|
+
if (withMetadata) {
|
|
27
|
+
streamMessage = (0, sdk_1.convertBytesToStreamMessage)(data);
|
|
28
|
+
content = streamMessage.content;
|
|
29
|
+
metadata = {
|
|
30
|
+
timestamp: streamMessage.getTimestamp(),
|
|
31
|
+
msgChainId: streamMessage.getMsgChainId()
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
else {
|
|
35
|
+
content = data;
|
|
36
|
+
metadata = {};
|
|
37
|
+
}
|
|
28
38
|
}
|
|
29
39
|
else {
|
|
40
|
+
// ignore newlines, etc
|
|
41
|
+
if (!data || String(data).trim() === '') {
|
|
42
|
+
done();
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const trimmedData = String(data).trim();
|
|
30
46
|
try {
|
|
31
|
-
|
|
47
|
+
if (withMetadata) {
|
|
48
|
+
const payload = JSON.parse(trimmedData);
|
|
49
|
+
if (payload.content === undefined) {
|
|
50
|
+
throw new Error('invalid input: no content');
|
|
51
|
+
}
|
|
52
|
+
content = isHexadecimal(payload.content) ? (0, utils_1.hexToBinary)(payload.content) : payload.content;
|
|
53
|
+
metadata = payload.metadata ?? {};
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
content = isHexadecimal(trimmedData) ? (0, utils_1.hexToBinary)(trimmedData) : JSON.parse(trimmedData);
|
|
57
|
+
metadata = {};
|
|
58
|
+
}
|
|
32
59
|
}
|
|
33
60
|
catch (e) {
|
|
34
61
|
console.error(data.toString());
|
|
@@ -36,17 +63,41 @@ const publishStream = (stream, partitionKeyField, client) => {
|
|
|
36
63
|
return;
|
|
37
64
|
}
|
|
38
65
|
}
|
|
39
|
-
|
|
40
|
-
|
|
66
|
+
if (raw) {
|
|
67
|
+
if (streamMessage.getStreamId() !== fullStreamId) {
|
|
68
|
+
throw new Error(`invalid input: stream IDs don't match: expected=${fullStreamId}, actual=${streamMessage.getStreamId()}`);
|
|
69
|
+
}
|
|
70
|
+
client.publishRaw(streamMessage).then(() => done(), (err) => done(err));
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
const partitionKey = (partitionKeyField !== undefined && typeof content === 'object') ? content[partitionKeyField] : undefined;
|
|
74
|
+
client.publish({ streamId, partition }, content, (0, utils_1.merge)(metadata, { partitionKey })).then(() => done(), (err) => done(err));
|
|
75
|
+
}
|
|
41
76
|
}
|
|
42
77
|
});
|
|
43
78
|
return writable;
|
|
44
79
|
};
|
|
45
80
|
(0, command_1.createClientCommand)(async (client, streamId, options) => {
|
|
46
|
-
|
|
81
|
+
if ((options.partition !== undefined) && (options.partitionKeyField !== undefined)) {
|
|
82
|
+
console.error('Invalid combination of "partition" and "partition-key-field"');
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
if (options.raw) {
|
|
86
|
+
if (!options.binary || !options.withMetadata) {
|
|
87
|
+
console.error('raw publish not supported when publishing without metadata and binary');
|
|
88
|
+
process.exit(1);
|
|
89
|
+
}
|
|
90
|
+
if (options.partitionKeyField !== undefined) {
|
|
91
|
+
console.error('partition key field not supported when publishing raw');
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
const ps = await publishStream(streamId, options.partition, options.partitionKeyField, options.raw, options.withMetadata, options.binary, client);
|
|
47
96
|
return new Promise((resolve, reject) => {
|
|
48
|
-
|
|
49
|
-
.pipe(
|
|
97
|
+
const inputStream = options.binary
|
|
98
|
+
? process.stdin.pipe(new utils_1.LengthPrefixedFrameDecoder())
|
|
99
|
+
: process.stdin.pipe(event_stream_1.default.split());
|
|
100
|
+
inputStream
|
|
50
101
|
.pipe(ps)
|
|
51
102
|
.once('finish', async () => {
|
|
52
103
|
// We need to wait some time because the client.publish() may resolve the promise
|
|
@@ -64,7 +115,11 @@ const publishStream = (stream, partitionKeyField, client) => {
|
|
|
64
115
|
})
|
|
65
116
|
.arguments('<streamId>')
|
|
66
117
|
.description('publish to a stream by reading JSON messages from stdin line-by-line or hexadecimal strings for binary data')
|
|
118
|
+
.option('-p, --partition <partition>', 'partition', (0, common_1.createFnParseInt)('--partition'))
|
|
67
119
|
// eslint-disable-next-line max-len
|
|
68
120
|
.option('-k, --partition-key-field <string>', 'field name in each message to use for assigning the message to a stream partition (only for JSON data)')
|
|
121
|
+
.option('-r, --raw', 'publish raw', false)
|
|
122
|
+
.option('-m, --with-metadata', 'each input contains both the content and the metadata', false)
|
|
123
|
+
.option('-b, --binary', 'binary input using length-prefixed frames', false)
|
|
69
124
|
.parseAsync();
|
|
70
125
|
//# sourceMappingURL=streamr-stream-publish.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamr-stream-publish.js","sourceRoot":"","sources":["../../bin/streamr-stream-publish.ts"],"names":[],"mappings":";;;;;;AACA,2BAAwB;AAExB,
|
|
1
|
+
{"version":3,"file":"streamr-stream-publish.js","sourceRoot":"","sources":["../../bin/streamr-stream-publish.ts"],"names":[],"mappings":";;;;;;AACA,2BAAwB;AAExB,sCAAyG;AACzG,0CAAoH;AACpH,gEAA6B;AAC7B,mCAAiC;AACjC,4CAA4E;AAC5E,0CAAgD;AAUhD,MAAM,aAAa,GAAG,CAAC,GAAW,EAAW,EAAE;IAC3C,OAAO,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AACrC,CAAC,CAAA;AAED,MAAM,aAAa,GAAG,KAAK,EACvB,QAAgB,EAChB,SAA6B,EAC7B,iBAAqC,EACrC,GAAY,EACZ,YAAqB,EACrB,MAAe,EACf,MAAqB,EACJ,EAAE;IACnB,MAAM,YAAY,GAAG,IAAA,kBAAU,EAAC,QA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W,GAAG,OAAO,CAAC,MAAM;YAC9B,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,kCAA0B,EAAE,CAAC;YACtD,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,sBAAE,CAAC,KAAK,EAAE,CAAC,CAAA;QACpC,WAAW;aACN,IAAI,CAAC,EAAE,CAAC;aACR,IAAI,CAAC,QAAQ,EAAE,KAAK,IAAI,EAAE;YACvB,iFAAiF;YACjF,2EAA2E;YAC3E,iFAAiF;YACjF,2EAA2E;YAC3E,sFAAsF;YACtF,uDAAuD;YACvD,MAAM,IAAA,YAAI,EAAC,IAAI,CAAC,CAAA;YAChB,OAAO,CAAC,SAAS,CAAC,CAAA;QACtB,CAAC,CAAC;YACF,2EAA2E;aAC1E,IAAI,CAAC,OAAO,EAAE,CAAC,GAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,CAAE,CAAA;IAClD,CAAC,CAAC,CAAA;AACN,CAAC,CAAC;KACG,SAAS,CAAC,YAAY,CAAC;KACvB,WAAW,CAAC,6GAA6G,CAAC;KAC1H,MAAM,CAAC,6BAA6B,EAAE,WAAW,EAAE,IAAA,yBAAgB,EAAC,aAAa,CAAC,CAAC;IACpF,mCAAmC;KAClC,MAAM,CAAC,oCAAoC,EAAE,wGAAwG,CAAC;KACtJ,MAAM,CAAC,WAAW,EAAE,aAAa,EAAE,KAAK,CAAC;KACzC,MAAM,CAAC,qBAAqB,EAAE,uDAAuD,EAAE,KAAK,CAAC;KAC7F,MAAM,CAAC,cAAc,EAAE,2CAA2C,EAAE,KAAK,CAAC;KAC1E,UAAU,EAAE,CAAA"}
|
|
@@ -5,24 +5,43 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
};
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
require("../src/logLevel");
|
|
8
|
-
const
|
|
8
|
+
const sdk_1 = require("@streamr/sdk");
|
|
9
|
+
const utils_1 = require("@streamr/utils");
|
|
10
|
+
const mapValues_1 = __importDefault(require("lodash/mapValues"));
|
|
9
11
|
const isString_1 = __importDefault(require("lodash/isString"));
|
|
12
|
+
const omit_1 = __importDefault(require("lodash/omit"));
|
|
10
13
|
const command_1 = require("../src/command");
|
|
11
14
|
const common_1 = require("../src/common");
|
|
12
|
-
const
|
|
15
|
+
const withBinaryFieldsAsHex = (metadata) => {
|
|
16
|
+
return (0, mapValues_1.default)(metadata, (value) => value instanceof Uint8Array ? (0, utils_1.binaryToHex)(value) : value);
|
|
17
|
+
};
|
|
13
18
|
(0, command_1.createClientCommand)(async (client, streamId, options) => {
|
|
14
|
-
const
|
|
15
|
-
const formMessage = options.withMetadata
|
|
16
|
-
? (content, metadata) => ({ content: formContent(content), metadata: (0, omit_1.default)(metadata, 'streamMessage') })
|
|
17
|
-
: (content) => formContent(content);
|
|
18
|
-
await client.subscribe({
|
|
19
|
+
const sub = await client.subscribe({
|
|
19
20
|
streamId,
|
|
20
21
|
partition: options.partition,
|
|
21
22
|
raw: options.raw
|
|
22
|
-
}, (content, metadata) => {
|
|
23
|
-
const output = formMessage(content, metadata);
|
|
24
|
-
console.info((0, isString_1.default)(output) ? output : JSON.stringify(output));
|
|
25
23
|
});
|
|
24
|
+
for await (const msg of sub) {
|
|
25
|
+
if (options.binary) {
|
|
26
|
+
// @ts-expect-error private field
|
|
27
|
+
const streamMessage = msg.streamMessage;
|
|
28
|
+
const binaryData = options.withMetadata
|
|
29
|
+
? (0, sdk_1.convertStreamMessageToBytes)(streamMessage)
|
|
30
|
+
: streamMessage.content;
|
|
31
|
+
process.stdout.write((0, utils_1.toLengthPrefixedFrame)(binaryData));
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
const formContent = (content) => content instanceof Uint8Array ? (0, utils_1.binaryToHex)(content) : content;
|
|
35
|
+
const formMessage = options.withMetadata
|
|
36
|
+
? (content, metadata) => ({
|
|
37
|
+
content: formContent(content),
|
|
38
|
+
metadata: withBinaryFieldsAsHex((0, omit_1.default)(metadata, 'streamMessage'))
|
|
39
|
+
})
|
|
40
|
+
: (content) => formContent(content);
|
|
41
|
+
const output = formMessage(msg.content, (0, omit_1.default)(msg, 'content'));
|
|
42
|
+
console.info((0, isString_1.default)(output) ? output : JSON.stringify(output));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
26
45
|
}, {
|
|
27
46
|
autoDestroyClient: false,
|
|
28
47
|
clientOptionsFactory: (options) => ({
|
|
@@ -31,9 +50,10 @@ const utils_1 = require("@streamr/utils");
|
|
|
31
50
|
})
|
|
32
51
|
.arguments('<streamId>')
|
|
33
52
|
.description('subscribe to a stream, prints JSON messages to stdout line-by-line')
|
|
34
|
-
.option('-p, --partition
|
|
53
|
+
.option('-p, --partition <partition>', 'partition', (0, common_1.createFnParseInt)('--partition'), 0)
|
|
35
54
|
.option('-d, --disable-ordering', 'disable ordering of messages by OrderingUtil', false)
|
|
36
55
|
.option('-r, --raw', 'subscribe raw', false)
|
|
37
56
|
.option('-m, --with-metadata', 'print each message with its metadata included', false)
|
|
57
|
+
.option('-b, --binary', 'binary output using length-prefixed frames', false)
|
|
38
58
|
.parseAsync();
|
|
39
59
|
//# sourceMappingURL=streamr-stream-subscribe.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"streamr-stream-subscribe.js","sourceRoot":"","sources":["../../bin/streamr-stream-subscribe.ts"],"names":[],"mappings":";;;;;;AACA,2BAAwB;AAExB,
|
|
1
|
+
{"version":3,"file":"streamr-stream-subscribe.js","sourceRoot":"","sources":["../../bin/streamr-stream-subscribe.ts"],"names":[],"mappings":";;;;;;AACA,2BAAwB;AAExB,sCAA8G;AAC9G,0CAAmE;AACnE,iEAAwC;AACxC,+DAAsC;AACtC,uDAA8B;AAC9B,4CAA4E;AAC5E,0CAAgD;AAUhD,MAAM,qBAAqB,GAAG,CAAC,QAA6B,EAAE,EAAE;IAC5D,OAAO,IAAA,mBAAS,EAAC,QAAQ,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AC,CAAC,CAAC,OAAgB,EAAE,EAAE,CAAC,WAAW,CAAC,OAAO,CAAC,CAAA;YAChD,MAAM,MAAM,GAAG,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,IAAA,cAAI,EAAC,GAAG,EAAE,SAAS,CAAC,CAAC,CAAA;YAC7D,OAAO,CAAC,IAAI,CAAC,IAAA,kBAAQ,EAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAA;QACpE,CAAC;IACL,CAAC;AACL,CAAC,EAAE;IACC,iBAAiB,EAAE,KAAK;IACxB,oBAAoB,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC;QAChC,aAAa,EAAE,CAAC,OAAO,CAAC,eAAe;KAC1C,CAAC;CACL,CAAC;KACG,SAAS,CAAC,YAAY,CAAC;KACvB,WAAW,CAAC,oEAAoE,CAAC;KACjF,MAAM,CAAC,6BAA6B,EAAE,WAAW,EAAE,IAAA,yBAAgB,EAAC,aAAa,CAAC,EAAE,CAAC,CAAC;KACtF,MAAM,CAAC,wBAAwB,EAAE,8CAA8C,EAAE,KAAK,CAAC;KACvF,MAAM,CAAC,WAAW,EAAE,eAAe,EAAE,KAAK,CAAC;KAC3C,MAAM,CAAC,qBAAqB,EAAE,+CAA+C,EAAE,KAAK,CAAC;KACrF,MAAM,CAAC,cAAc,EAAE,4CAA4C,EAAE,KAAK,CAAC;KAC3E,UAAU,EAAE,CAAA"}
|
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamr/cli-tools",
|
|
3
|
-
"version": "103.
|
|
3
|
+
"version": "103.2.0-experiment.0",
|
|
4
4
|
"description": "Command line tools for Streamr",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"streamr": "dist/bin/streamr.js"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
|
-
"build": "tsc -b
|
|
21
|
-
"check": "tsc -p
|
|
22
|
-
"clean": "jest --clearCache || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
|
|
20
|
+
"build": "tsc -b",
|
|
21
|
+
"check": "tsc -p tsconfig.jest.json",
|
|
22
|
+
"clean": "jest --clearCache --config '{}' || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
|
|
23
23
|
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
|
|
24
24
|
"test": "npm run build && jest --bail --forceExit"
|
|
25
25
|
},
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"author": "Streamr Network AG <contact@streamr.com>",
|
|
33
33
|
"license": "AGPL-3.0",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@streamr/config": "^5.9.
|
|
36
|
-
"@streamr/dht": "103.
|
|
35
|
+
"@streamr/config": "^5.9.2",
|
|
36
|
+
"@streamr/dht": "103.2.0-experiment.0",
|
|
37
37
|
"@streamr/network-contracts": "^9.1.0",
|
|
38
|
-
"@streamr/sdk": "103.
|
|
39
|
-
"@streamr/trackerless-network": "103.
|
|
40
|
-
"@streamr/utils": "103.
|
|
38
|
+
"@streamr/sdk": "103.2.0-experiment.0",
|
|
39
|
+
"@streamr/trackerless-network": "103.2.0-experiment.0",
|
|
40
|
+
"@streamr/utils": "103.2.0-experiment.0",
|
|
41
41
|
"commander": "^14.0.2",
|
|
42
42
|
"easy-table": "^1.1.1",
|
|
43
43
|
"ethers": "^6.13.0",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"semver": "^7.7.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@streamr/test-utils": "103.
|
|
49
|
+
"@streamr/test-utils": "103.2.0-experiment.0",
|
|
50
50
|
"@types/event-stream": "^4.0.6",
|
|
51
|
-
"@types/lodash": "^4.17.
|
|
51
|
+
"@types/lodash": "^4.17.21",
|
|
52
52
|
"@types/merge2": "^1.4.4",
|
|
53
53
|
"@types/semver": "^7.7.1",
|
|
54
54
|
"merge2": "^1.4.1"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamr/cli-tools",
|
|
3
|
-
"version": "103.
|
|
3
|
+
"version": "103.2.0-experiment.0",
|
|
4
4
|
"description": "Command line tools for Streamr",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"streamr": "dist/bin/streamr.js"
|
|
18
18
|
},
|
|
19
19
|
"scripts": {
|
|
20
|
-
"build": "tsc -b
|
|
21
|
-
"check": "tsc -p
|
|
22
|
-
"clean": "jest --clearCache || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
|
|
20
|
+
"build": "tsc -b",
|
|
21
|
+
"check": "tsc -p tsconfig.jest.json",
|
|
22
|
+
"clean": "jest --clearCache --config '{}' || true; rm -rf dist *.tsbuildinfo node_modules/.cache || true",
|
|
23
23
|
"eslint": "eslint --cache --cache-location=node_modules/.cache/.eslintcache/ '*/**/*.{js,ts}'",
|
|
24
24
|
"test": "npm run build && jest --bail --forceExit"
|
|
25
25
|
},
|
|
@@ -32,12 +32,12 @@
|
|
|
32
32
|
"author": "Streamr Network AG <contact@streamr.com>",
|
|
33
33
|
"license": "AGPL-3.0",
|
|
34
34
|
"dependencies": {
|
|
35
|
-
"@streamr/config": "^5.9.
|
|
36
|
-
"@streamr/dht": "103.
|
|
35
|
+
"@streamr/config": "^5.9.2",
|
|
36
|
+
"@streamr/dht": "103.2.0-experiment.0",
|
|
37
37
|
"@streamr/network-contracts": "^9.1.0",
|
|
38
|
-
"@streamr/sdk": "103.
|
|
39
|
-
"@streamr/trackerless-network": "103.
|
|
40
|
-
"@streamr/utils": "103.
|
|
38
|
+
"@streamr/sdk": "103.2.0-experiment.0",
|
|
39
|
+
"@streamr/trackerless-network": "103.2.0-experiment.0",
|
|
40
|
+
"@streamr/utils": "103.2.0-experiment.0",
|
|
41
41
|
"commander": "^14.0.2",
|
|
42
42
|
"easy-table": "^1.1.1",
|
|
43
43
|
"ethers": "^6.13.0",
|
|
@@ -46,9 +46,9 @@
|
|
|
46
46
|
"semver": "^7.7.3"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@streamr/test-utils": "103.
|
|
49
|
+
"@streamr/test-utils": "103.2.0-experiment.0",
|
|
50
50
|
"@types/event-stream": "^4.0.6",
|
|
51
|
-
"@types/lodash": "^4.17.
|
|
51
|
+
"@types/lodash": "^4.17.21",
|
|
52
52
|
"@types/merge2": "^1.4.4",
|
|
53
53
|
"@types/semver": "^7.7.1",
|
|
54
54
|
"merge2": "^1.4.1"
|