@peerbit/server 4.0.3 → 4.0.4
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/lib/esm/aws.js +27 -27
- package/lib/esm/aws.js.map +1 -1
- package/lib/esm/cli.js +97 -97
- package/lib/esm/cli.js.map +1 -1
- package/lib/esm/client.js +24 -24
- package/lib/esm/client.js.map +1 -1
- package/lib/esm/docker.js +1 -1
- package/lib/esm/peerbit.js +8 -8
- package/lib/esm/remotes.js +1 -1
- package/lib/esm/server.js +10 -10
- package/lib/esm/server.js.map +1 -1
- package/lib/esm/session.js +2 -2
- package/lib/esm/signes-request.js +1 -1
- package/lib/esm/signes-request.js.map +1 -1
- package/package.json +4 -4
- package/src/aws.ts +27 -27
- package/src/cli.ts +101 -103
- package/src/client.ts +24 -24
- package/src/docker.ts +1 -1
- package/src/peerbit.ts +8 -8
- package/src/remotes.ts +1 -1
- package/src/server.ts +11 -11
- package/src/session.ts +2 -2
- package/src/signes-request.ts +1 -1
package/src/cli.ts
CHANGED
|
@@ -2,20 +2,20 @@ import {
|
|
|
2
2
|
createTestDomain,
|
|
3
3
|
getDomainFromConfig,
|
|
4
4
|
loadConfig,
|
|
5
|
-
startCertbot
|
|
5
|
+
startCertbot
|
|
6
6
|
} from "./domain.js";
|
|
7
7
|
import { startServerWithNode } from "./server.js";
|
|
8
8
|
import {
|
|
9
9
|
AWS_LINUX_ARM_AMIs,
|
|
10
10
|
createRecord,
|
|
11
11
|
launchNodes,
|
|
12
|
-
terminateNode
|
|
12
|
+
terminateNode
|
|
13
13
|
} from "./aws.js";
|
|
14
14
|
import {
|
|
15
15
|
getHomeConfigDir,
|
|
16
16
|
getKeypair,
|
|
17
17
|
getPackageName,
|
|
18
|
-
getRemotesPath
|
|
18
|
+
getRemotesPath
|
|
19
19
|
} from "./config.js";
|
|
20
20
|
import chalk from "chalk";
|
|
21
21
|
import { createClient, waitForDomain } from "./client.js";
|
|
@@ -95,7 +95,7 @@ const colors = [
|
|
|
95
95
|
"#A5FFD2",
|
|
96
96
|
"#FFB167",
|
|
97
97
|
"#009BFF",
|
|
98
|
-
"#E85EBE"
|
|
98
|
+
"#E85EBE"
|
|
99
99
|
];
|
|
100
100
|
const padString = function (
|
|
101
101
|
string: string,
|
|
@@ -135,12 +135,12 @@ export const cli = async (args?: string[]) => {
|
|
|
135
135
|
defaultDescription: "~.peerbit",
|
|
136
136
|
type: "string",
|
|
137
137
|
alias: "d",
|
|
138
|
-
default: getHomeConfigDir()
|
|
138
|
+
default: getHomeConfigDir()
|
|
139
139
|
})
|
|
140
140
|
.option("bootstrap", {
|
|
141
141
|
describe: "Whether to connect to bootstap nodes on startup",
|
|
142
142
|
type: "boolean",
|
|
143
|
-
default: false
|
|
143
|
+
default: false
|
|
144
144
|
})
|
|
145
145
|
.option("grant-access", {
|
|
146
146
|
describe: "Grant access to public keys on start",
|
|
@@ -148,26 +148,26 @@ export const cli = async (args?: string[]) => {
|
|
|
148
148
|
"The publickey of this device located in 'directory'",
|
|
149
149
|
type: "string",
|
|
150
150
|
array: true,
|
|
151
|
-
alias: "ga"
|
|
151
|
+
alias: "ga"
|
|
152
152
|
})
|
|
153
153
|
.option("reset", {
|
|
154
154
|
describe:
|
|
155
155
|
"If true, then programs opened during last session will not be opened",
|
|
156
156
|
type: "boolean",
|
|
157
157
|
default: false,
|
|
158
|
-
alias: "r"
|
|
158
|
+
alias: "r"
|
|
159
159
|
})
|
|
160
160
|
.option("port-api", {
|
|
161
161
|
describe:
|
|
162
162
|
"Set API server port. Only modify this when testing locally, since NGINX config depends on the default value",
|
|
163
163
|
type: "number",
|
|
164
|
-
default: undefined
|
|
164
|
+
default: undefined
|
|
165
165
|
})
|
|
166
166
|
.option("port-node", {
|
|
167
167
|
describe:
|
|
168
168
|
"Set Libp2p listen port. Only modify this when testing locally, since NGINX config depends on the default value",
|
|
169
169
|
type: "number",
|
|
170
|
-
default: undefined
|
|
170
|
+
default: undefined
|
|
171
171
|
});
|
|
172
172
|
return yargs;
|
|
173
173
|
},
|
|
@@ -180,9 +180,9 @@ export const cli = async (args?: string[]) => {
|
|
|
180
180
|
ports: { api: args["port-api"], node: args["port-node"] },
|
|
181
181
|
bootstrap: args.bootstrap,
|
|
182
182
|
newSession: args.reset,
|
|
183
|
-
grantAccess: args["grant-access"]
|
|
183
|
+
grantAccess: args["grant-access"]
|
|
184
184
|
});
|
|
185
|
-
}
|
|
185
|
+
}
|
|
186
186
|
})
|
|
187
187
|
.command({
|
|
188
188
|
command: "id",
|
|
@@ -193,14 +193,14 @@ export const cli = async (args?: string[]) => {
|
|
|
193
193
|
defaultDescription: "~.peerbit",
|
|
194
194
|
type: "string",
|
|
195
195
|
alias: "d",
|
|
196
|
-
default: getHomeConfigDir()
|
|
196
|
+
default: getHomeConfigDir()
|
|
197
197
|
});
|
|
198
198
|
return yargs;
|
|
199
199
|
},
|
|
200
200
|
handler: async (args) => {
|
|
201
201
|
const kp = await getKeypair(args.directory);
|
|
202
202
|
console.log((await kp.toPeerId()).toString());
|
|
203
|
-
}
|
|
203
|
+
}
|
|
204
204
|
})
|
|
205
205
|
.command(
|
|
206
206
|
"domain",
|
|
@@ -215,25 +215,25 @@ export const cli = async (args?: string[]) => {
|
|
|
215
215
|
email: {
|
|
216
216
|
describe: "Email for Lets encrypt autorenewal messages",
|
|
217
217
|
type: "string",
|
|
218
|
-
demandOption: true
|
|
218
|
+
demandOption: true
|
|
219
219
|
},
|
|
220
220
|
outdir: {
|
|
221
221
|
describe: "Output path for Nginx config",
|
|
222
222
|
type: "string",
|
|
223
|
-
alias: "o"
|
|
223
|
+
alias: "o"
|
|
224
224
|
},
|
|
225
225
|
wait: {
|
|
226
226
|
alias: "w",
|
|
227
227
|
describe: "Wait for setup to succeed (or fail)",
|
|
228
228
|
type: "boolean",
|
|
229
|
-
default: false
|
|
230
|
-
}
|
|
229
|
+
default: false
|
|
230
|
+
}
|
|
231
231
|
},
|
|
232
232
|
handler: async (args) => {
|
|
233
233
|
const domain = await createTestDomain();
|
|
234
234
|
await startCertbot(domain, args.email, args.outdir, args.wait);
|
|
235
235
|
exit();
|
|
236
|
-
}
|
|
236
|
+
}
|
|
237
237
|
})
|
|
238
238
|
.command({
|
|
239
239
|
command: "aws",
|
|
@@ -244,45 +244,45 @@ export const cli = async (args?: string[]) => {
|
|
|
244
244
|
describe: "domain, e.g. abc.example.com, example.com",
|
|
245
245
|
alias: "d",
|
|
246
246
|
type: "string",
|
|
247
|
-
demandOption: true
|
|
247
|
+
demandOption: true
|
|
248
248
|
},
|
|
249
249
|
hostedZoneId: {
|
|
250
250
|
describe: 'The id of the hosted zone "HostedZoneId"',
|
|
251
251
|
alias: "hz",
|
|
252
252
|
type: "string",
|
|
253
|
-
require: true
|
|
253
|
+
require: true
|
|
254
254
|
},
|
|
255
255
|
accessKeyId: {
|
|
256
256
|
describe: "Access key id of the AWS user",
|
|
257
257
|
alias: "ak",
|
|
258
|
-
type: "string"
|
|
258
|
+
type: "string"
|
|
259
259
|
},
|
|
260
260
|
region: {
|
|
261
261
|
describe: "AWS region",
|
|
262
262
|
alias: "r",
|
|
263
|
-
type: "string"
|
|
263
|
+
type: "string"
|
|
264
264
|
},
|
|
265
265
|
secretAccessKey: {
|
|
266
266
|
describe: "Secret key id of the AWS user",
|
|
267
267
|
alias: "sk",
|
|
268
|
-
type: "string"
|
|
268
|
+
type: "string"
|
|
269
269
|
},
|
|
270
270
|
email: {
|
|
271
271
|
describe: "Email for Lets encrypt auto-renewal messages",
|
|
272
272
|
type: "string",
|
|
273
|
-
demandOption: true
|
|
273
|
+
demandOption: true
|
|
274
274
|
},
|
|
275
275
|
outdir: {
|
|
276
276
|
describe: "Output path for Nginx config",
|
|
277
277
|
type: "string",
|
|
278
|
-
alias: "o"
|
|
278
|
+
alias: "o"
|
|
279
279
|
},
|
|
280
280
|
wait: {
|
|
281
281
|
alias: "w",
|
|
282
282
|
describe: "Wait for setup to succeed (or fail)",
|
|
283
283
|
type: "boolean",
|
|
284
|
-
default: false
|
|
285
|
-
}
|
|
284
|
+
default: false
|
|
285
|
+
}
|
|
286
286
|
},
|
|
287
287
|
handler: async (args) => {
|
|
288
288
|
if (
|
|
@@ -300,9 +300,9 @@ export const cli = async (args?: string[]) => {
|
|
|
300
300
|
credentials: args.accessKeyId
|
|
301
301
|
? {
|
|
302
302
|
accessKeyId: args.accessKeyId,
|
|
303
|
-
secretAccessKey: args.secretAccessKey
|
|
303
|
+
secretAccessKey: args.secretAccessKey
|
|
304
304
|
}
|
|
305
|
-
: undefined
|
|
305
|
+
: undefined
|
|
306
306
|
});
|
|
307
307
|
await startCertbot(
|
|
308
308
|
args.domain,
|
|
@@ -311,7 +311,7 @@ export const cli = async (args?: string[]) => {
|
|
|
311
311
|
args.wait
|
|
312
312
|
);
|
|
313
313
|
exit();
|
|
314
|
-
}
|
|
314
|
+
}
|
|
315
315
|
})
|
|
316
316
|
.strict()
|
|
317
317
|
.demandCommand();
|
|
@@ -330,19 +330,19 @@ export const cli = async (args?: string[]) => {
|
|
|
330
330
|
defaultDescription: "One node",
|
|
331
331
|
type: "number",
|
|
332
332
|
alias: "c",
|
|
333
|
-
default: 1
|
|
333
|
+
default: 1
|
|
334
334
|
});
|
|
335
335
|
awsArgs.option("region", {
|
|
336
336
|
describe: "Region",
|
|
337
337
|
type: "string",
|
|
338
338
|
defaultDescription: "Region defined in ~.aws/config",
|
|
339
|
-
choices: Object.keys(AWS_LINUX_ARM_AMIs)
|
|
339
|
+
choices: Object.keys(AWS_LINUX_ARM_AMIs)
|
|
340
340
|
});
|
|
341
341
|
awsArgs.option("group", {
|
|
342
342
|
describe: "Remote group to launch nodes in",
|
|
343
343
|
type: "string",
|
|
344
344
|
alias: "g",
|
|
345
|
-
default: DEFAULT_REMOTE_GROUP
|
|
345
|
+
default: DEFAULT_REMOTE_GROUP
|
|
346
346
|
});
|
|
347
347
|
awsArgs.option("size", {
|
|
348
348
|
describe: "Instance size",
|
|
@@ -354,16 +354,16 @@ export const cli = async (args?: string[]) => {
|
|
|
354
354
|
"medium",
|
|
355
355
|
"large",
|
|
356
356
|
"xlarge",
|
|
357
|
-
"2xlarge"
|
|
357
|
+
"2xlarge"
|
|
358
358
|
],
|
|
359
|
-
default: "micro"
|
|
359
|
+
default: "micro"
|
|
360
360
|
});
|
|
361
361
|
|
|
362
362
|
awsArgs.option("name", {
|
|
363
363
|
describe: "Name prefix for spawned nodes",
|
|
364
364
|
type: "string",
|
|
365
365
|
alias: "n",
|
|
366
|
-
default: "peerbit-node"
|
|
366
|
+
default: "peerbit-node"
|
|
367
367
|
});
|
|
368
368
|
awsArgs.option("grant-access", {
|
|
369
369
|
describe: "Grant access to public keys on start",
|
|
@@ -371,14 +371,14 @@ export const cli = async (args?: string[]) => {
|
|
|
371
371
|
"The publickey of this device located in 'directory'",
|
|
372
372
|
type: "string",
|
|
373
373
|
array: true,
|
|
374
|
-
alias: "ga"
|
|
374
|
+
alias: "ga"
|
|
375
375
|
});
|
|
376
376
|
awsArgs.option("directory", {
|
|
377
377
|
describe: "Peerbit directory",
|
|
378
378
|
defaultDescription: "~.peerbit",
|
|
379
379
|
type: "string",
|
|
380
380
|
alias: "d",
|
|
381
|
-
default: getHomeConfigDir()
|
|
381
|
+
default: getHomeConfigDir()
|
|
382
382
|
});
|
|
383
383
|
return awsArgs;
|
|
384
384
|
},
|
|
@@ -389,7 +389,7 @@ export const cli = async (args?: string[]) => {
|
|
|
389
389
|
: [
|
|
390
390
|
await (
|
|
391
391
|
await getKeypair(args.directory)
|
|
392
|
-
).publicKey.toPeerId()
|
|
392
|
+
).publicKey.toPeerId()
|
|
393
393
|
];
|
|
394
394
|
const nodes = await launchNodes({
|
|
395
395
|
email: "marcus@dao.xyz",
|
|
@@ -397,7 +397,7 @@ export const cli = async (args?: string[]) => {
|
|
|
397
397
|
namePrefix: args.name,
|
|
398
398
|
region: args.region,
|
|
399
399
|
grantAccess: accessGrant,
|
|
400
|
-
size: args.size
|
|
400
|
+
size: args.size
|
|
401
401
|
});
|
|
402
402
|
|
|
403
403
|
console.log(
|
|
@@ -426,8 +426,8 @@ export const cli = async (args?: string[]) => {
|
|
|
426
426
|
origin: {
|
|
427
427
|
type: "aws",
|
|
428
428
|
instanceId: node.instanceId,
|
|
429
|
-
region: node.region
|
|
430
|
-
}
|
|
429
|
+
region: node.region
|
|
430
|
+
}
|
|
431
431
|
});
|
|
432
432
|
} catch (error: any) {
|
|
433
433
|
process.stdout.write("\r");
|
|
@@ -444,7 +444,7 @@ export const cli = async (args?: string[]) => {
|
|
|
444
444
|
for (const node of nodes) {
|
|
445
445
|
console.log(chalk.green(node.name));
|
|
446
446
|
}
|
|
447
|
-
}
|
|
447
|
+
}
|
|
448
448
|
})
|
|
449
449
|
.strict()
|
|
450
450
|
.demandCommand();
|
|
@@ -456,21 +456,21 @@ export const cli = async (args?: string[]) => {
|
|
|
456
456
|
killArgs.option("all", {
|
|
457
457
|
describe: "Kill all nodes",
|
|
458
458
|
type: "boolean",
|
|
459
|
-
default: false
|
|
459
|
+
default: false
|
|
460
460
|
});
|
|
461
461
|
killArgs.positional("name", {
|
|
462
462
|
type: "string",
|
|
463
463
|
describe: "Remote name",
|
|
464
464
|
default: "localhost",
|
|
465
465
|
demandOption: false,
|
|
466
|
-
array: true
|
|
466
|
+
array: true
|
|
467
467
|
});
|
|
468
468
|
killArgs.option("directory", {
|
|
469
469
|
describe: "Peerbit directory",
|
|
470
470
|
defaultDescription: "~.peerbit",
|
|
471
471
|
type: "string",
|
|
472
472
|
alias: "d",
|
|
473
|
-
default: getHomeConfigDir()
|
|
473
|
+
default: getHomeConfigDir()
|
|
474
474
|
});
|
|
475
475
|
return killArgs;
|
|
476
476
|
},
|
|
@@ -482,12 +482,12 @@ export const cli = async (args?: string[]) => {
|
|
|
482
482
|
if (remote.origin?.type === "aws") {
|
|
483
483
|
await terminateNode({
|
|
484
484
|
instanceId: remote.origin.instanceId,
|
|
485
|
-
region: remote.origin.region
|
|
485
|
+
region: remote.origin.region
|
|
486
486
|
});
|
|
487
487
|
}
|
|
488
488
|
}
|
|
489
489
|
}
|
|
490
|
-
}
|
|
490
|
+
}
|
|
491
491
|
})
|
|
492
492
|
.command({
|
|
493
493
|
command: "list",
|
|
@@ -499,7 +499,7 @@ export const cli = async (args?: string[]) => {
|
|
|
499
499
|
defaultDescription: "~.peerbit",
|
|
500
500
|
type: "string",
|
|
501
501
|
alias: "d",
|
|
502
|
-
default: getHomeConfigDir()
|
|
502
|
+
default: getHomeConfigDir()
|
|
503
503
|
});
|
|
504
504
|
|
|
505
505
|
return yargs;
|
|
@@ -530,7 +530,7 @@ export const cli = async (args?: string[]) => {
|
|
|
530
530
|
resolvedOrRejected[ix].status === "fulfilled"
|
|
531
531
|
? chalk.green("Y")
|
|
532
532
|
: chalk.red("N"),
|
|
533
|
-
remote.address
|
|
533
|
+
remote.address
|
|
534
534
|
];
|
|
535
535
|
rows.push(row);
|
|
536
536
|
}
|
|
@@ -544,7 +544,7 @@ export const cli = async (args?: string[]) => {
|
|
|
544
544
|
} else {
|
|
545
545
|
console.log("No remotes found!");
|
|
546
546
|
}
|
|
547
|
-
}
|
|
547
|
+
}
|
|
548
548
|
})
|
|
549
549
|
.command({
|
|
550
550
|
command: "add <name> <address>",
|
|
@@ -554,25 +554,25 @@ export const cli = async (args?: string[]) => {
|
|
|
554
554
|
.positional("name", {
|
|
555
555
|
type: "string",
|
|
556
556
|
describe: "Remote address",
|
|
557
|
-
demandOption: true
|
|
557
|
+
demandOption: true
|
|
558
558
|
})
|
|
559
559
|
.positional("address", {
|
|
560
560
|
type: "string",
|
|
561
561
|
describe: "Remote name",
|
|
562
|
-
demandOption: true
|
|
562
|
+
demandOption: true
|
|
563
563
|
})
|
|
564
564
|
.option("group", {
|
|
565
565
|
describe: "Group name",
|
|
566
566
|
type: "string",
|
|
567
567
|
alias: "g",
|
|
568
|
-
default: DEFAULT_REMOTE_GROUP
|
|
568
|
+
default: DEFAULT_REMOTE_GROUP
|
|
569
569
|
})
|
|
570
570
|
.option("directory", {
|
|
571
571
|
describe: "Peerbit directory",
|
|
572
572
|
defaultDescription: "~.peerbit",
|
|
573
573
|
type: "string",
|
|
574
574
|
alias: "d",
|
|
575
|
-
default: getHomeConfigDir()
|
|
575
|
+
default: getHomeConfigDir()
|
|
576
576
|
});
|
|
577
577
|
|
|
578
578
|
return yargs;
|
|
@@ -582,7 +582,7 @@ export const cli = async (args?: string[]) => {
|
|
|
582
582
|
throw new Error("Remote can not be named 'localhost'");
|
|
583
583
|
}
|
|
584
584
|
const api = await createClient(await getKeypair(args.directory), {
|
|
585
|
-
address: args.address
|
|
585
|
+
address: args.address
|
|
586
586
|
});
|
|
587
587
|
try {
|
|
588
588
|
await api.program.list();
|
|
@@ -596,9 +596,9 @@ export const cli = async (args?: string[]) => {
|
|
|
596
596
|
remotes.add({
|
|
597
597
|
name: args.name,
|
|
598
598
|
address: args.address,
|
|
599
|
-
group: args.group
|
|
599
|
+
group: args.group
|
|
600
600
|
});
|
|
601
|
-
}
|
|
601
|
+
}
|
|
602
602
|
})
|
|
603
603
|
.command({
|
|
604
604
|
command: "remove <name>",
|
|
@@ -609,14 +609,14 @@ export const cli = async (args?: string[]) => {
|
|
|
609
609
|
.positional("name", {
|
|
610
610
|
type: "string",
|
|
611
611
|
describe: "Remote address",
|
|
612
|
-
demandOption: true
|
|
612
|
+
demandOption: true
|
|
613
613
|
})
|
|
614
614
|
.option("directory", {
|
|
615
615
|
describe: "Peerbit directory",
|
|
616
616
|
defaultDescription: "~.peerbit",
|
|
617
617
|
type: "string",
|
|
618
618
|
alias: "d",
|
|
619
|
-
default: getHomeConfigDir()
|
|
619
|
+
default: getHomeConfigDir()
|
|
620
620
|
});
|
|
621
621
|
|
|
622
622
|
return yargs;
|
|
@@ -632,7 +632,7 @@ export const cli = async (args?: string[]) => {
|
|
|
632
632
|
chalk.red("Did not find any remote with name: " + args.name)
|
|
633
633
|
);
|
|
634
634
|
}
|
|
635
|
-
}
|
|
635
|
+
}
|
|
636
636
|
})
|
|
637
637
|
.command({
|
|
638
638
|
command: "connect [name...]",
|
|
@@ -644,26 +644,26 @@ export const cli = async (args?: string[]) => {
|
|
|
644
644
|
describe: "Remote name",
|
|
645
645
|
default: "localhost",
|
|
646
646
|
demandOption: false,
|
|
647
|
-
array: true
|
|
647
|
+
array: true
|
|
648
648
|
})
|
|
649
649
|
.option("all", {
|
|
650
650
|
type: "boolean",
|
|
651
651
|
describe: "Connect to all nodes",
|
|
652
|
-
default: false
|
|
652
|
+
default: false
|
|
653
653
|
})
|
|
654
654
|
.option("group", {
|
|
655
655
|
type: "string",
|
|
656
656
|
describe: "Remote group name",
|
|
657
657
|
alias: "g",
|
|
658
658
|
default: [],
|
|
659
|
-
array: true
|
|
659
|
+
array: true
|
|
660
660
|
})
|
|
661
661
|
.option("directory", {
|
|
662
662
|
describe: "Peerbit directory",
|
|
663
663
|
defaultDescription: "~.peerbit",
|
|
664
664
|
type: "string",
|
|
665
665
|
alias: "d",
|
|
666
|
-
default: getHomeConfigDir()
|
|
666
|
+
default: getHomeConfigDir()
|
|
667
667
|
});
|
|
668
668
|
return yargs;
|
|
669
669
|
},
|
|
@@ -694,7 +694,7 @@ export const cli = async (args?: string[]) => {
|
|
|
694
694
|
selectedRemotes.push({
|
|
695
695
|
address: "http://localhost:" + LOCAL_API_PORT,
|
|
696
696
|
name: "localhost",
|
|
697
|
-
group: DEFAULT_REMOTE_GROUP
|
|
697
|
+
group: DEFAULT_REMOTE_GROUP
|
|
698
698
|
});
|
|
699
699
|
} else {
|
|
700
700
|
const remote = remotes.getByName(name);
|
|
@@ -746,7 +746,7 @@ export const cli = async (args?: string[]) => {
|
|
|
746
746
|
apis.push({
|
|
747
747
|
log: logFn,
|
|
748
748
|
name: remote.name,
|
|
749
|
-
api: await createClient(keypair, remote)
|
|
749
|
+
api: await createClient(keypair, remote)
|
|
750
750
|
});
|
|
751
751
|
}
|
|
752
752
|
|
|
@@ -765,7 +765,7 @@ export const cli = async (args?: string[]) => {
|
|
|
765
765
|
input: process.stdin,
|
|
766
766
|
output: process.stdout,
|
|
767
767
|
terminal: true,
|
|
768
|
-
historySize: 100
|
|
768
|
+
historySize: 100
|
|
769
769
|
});
|
|
770
770
|
|
|
771
771
|
console.log("Write 'help' to show commands.\n");
|
|
@@ -782,7 +782,7 @@ export const cli = async (args?: string[]) => {
|
|
|
782
782
|
for (const api of apis) {
|
|
783
783
|
api.log((await api.api.peer.id.get()).toString());
|
|
784
784
|
}
|
|
785
|
-
}
|
|
785
|
+
}
|
|
786
786
|
})
|
|
787
787
|
.command({
|
|
788
788
|
command: "address",
|
|
@@ -793,7 +793,7 @@ export const cli = async (args?: string[]) => {
|
|
|
793
793
|
api.log(x.toString())
|
|
794
794
|
);
|
|
795
795
|
}
|
|
796
|
-
}
|
|
796
|
+
}
|
|
797
797
|
})
|
|
798
798
|
.strict()
|
|
799
799
|
.demandCommand();
|
|
@@ -811,7 +811,7 @@ export const cli = async (args?: string[]) => {
|
|
|
811
811
|
yargs.positional("peer-id", {
|
|
812
812
|
describe: "Peer id",
|
|
813
813
|
type: "string",
|
|
814
|
-
demandOption: true
|
|
814
|
+
demandOption: true
|
|
815
815
|
});
|
|
816
816
|
return yargs;
|
|
817
817
|
},
|
|
@@ -822,7 +822,7 @@ export const cli = async (args?: string[]) => {
|
|
|
822
822
|
for (const api of apis) {
|
|
823
823
|
await api.api.access.allow(peerId);
|
|
824
824
|
}
|
|
825
|
-
}
|
|
825
|
+
}
|
|
826
826
|
})
|
|
827
827
|
.command({
|
|
828
828
|
command: "deny <peer-id>",
|
|
@@ -830,7 +830,7 @@ export const cli = async (args?: string[]) => {
|
|
|
830
830
|
builder: (yargs: yargs.Argv) => {
|
|
831
831
|
yargs.positional("peer-id", {
|
|
832
832
|
describe: "Peer id",
|
|
833
|
-
demandOption: true
|
|
833
|
+
demandOption: true
|
|
834
834
|
});
|
|
835
835
|
return yargs;
|
|
836
836
|
},
|
|
@@ -839,7 +839,7 @@ export const cli = async (args?: string[]) => {
|
|
|
839
839
|
for (const api of apis) {
|
|
840
840
|
await api.api.access.deny(peerId);
|
|
841
841
|
}
|
|
842
|
-
}
|
|
842
|
+
}
|
|
843
843
|
})
|
|
844
844
|
.strict()
|
|
845
845
|
.demandCommand();
|
|
@@ -854,7 +854,7 @@ export const cli = async (args?: string[]) => {
|
|
|
854
854
|
for (const api of apis) {
|
|
855
855
|
await api.api.network.bootstrap();
|
|
856
856
|
}
|
|
857
|
-
}
|
|
857
|
+
}
|
|
858
858
|
})
|
|
859
859
|
.strict()
|
|
860
860
|
.demandCommand();
|
|
@@ -874,7 +874,7 @@ export const cli = async (args?: string[]) => {
|
|
|
874
874
|
type: "boolean",
|
|
875
875
|
describe: "Replicate data on this topic",
|
|
876
876
|
aliases: "r",
|
|
877
|
-
default: false
|
|
877
|
+
default: false
|
|
878
878
|
});
|
|
879
879
|
return yargs;
|
|
880
880
|
},
|
|
@@ -890,7 +890,7 @@ export const cli = async (args?: string[]) => {
|
|
|
890
890
|
console.log("Not subscribed to any topics");
|
|
891
891
|
} */
|
|
892
892
|
console.error("Not implemented");
|
|
893
|
-
}
|
|
893
|
+
}
|
|
894
894
|
})
|
|
895
895
|
.strict()
|
|
896
896
|
.demandCommand();
|
|
@@ -906,7 +906,7 @@ export const cli = async (args?: string[]) => {
|
|
|
906
906
|
yargs.positional("address", {
|
|
907
907
|
type: "string",
|
|
908
908
|
describe: "Program address",
|
|
909
|
-
demandOption: true
|
|
909
|
+
demandOption: true
|
|
910
910
|
});
|
|
911
911
|
return yargs;
|
|
912
912
|
},
|
|
@@ -922,7 +922,7 @@ export const cli = async (args?: string[]) => {
|
|
|
922
922
|
api.log(chalk.green("Open"));
|
|
923
923
|
}
|
|
924
924
|
}
|
|
925
|
-
}
|
|
925
|
+
}
|
|
926
926
|
})
|
|
927
927
|
.command({
|
|
928
928
|
command: "drop <address>",
|
|
@@ -931,7 +931,7 @@ export const cli = async (args?: string[]) => {
|
|
|
931
931
|
yargs.positional("address", {
|
|
932
932
|
type: "string",
|
|
933
933
|
describe: "Program address",
|
|
934
|
-
demandOption: true
|
|
934
|
+
demandOption: true
|
|
935
935
|
});
|
|
936
936
|
return yargs;
|
|
937
937
|
},
|
|
@@ -950,7 +950,7 @@ export const cli = async (args?: string[]) => {
|
|
|
950
950
|
);
|
|
951
951
|
}
|
|
952
952
|
}
|
|
953
|
-
}
|
|
953
|
+
}
|
|
954
954
|
})
|
|
955
955
|
.command({
|
|
956
956
|
command: "close <address>",
|
|
@@ -959,7 +959,7 @@ export const cli = async (args?: string[]) => {
|
|
|
959
959
|
yargs.positional("address", {
|
|
960
960
|
type: "string",
|
|
961
961
|
describe: "Program address",
|
|
962
|
-
demandOption: true
|
|
962
|
+
demandOption: true
|
|
963
963
|
});
|
|
964
964
|
return yargs;
|
|
965
965
|
},
|
|
@@ -968,7 +968,7 @@ export const cli = async (args?: string[]) => {
|
|
|
968
968
|
for (const api of apis) {
|
|
969
969
|
await api.api.program.close(args.address);
|
|
970
970
|
}
|
|
971
|
-
}
|
|
971
|
+
}
|
|
972
972
|
})
|
|
973
973
|
.command({
|
|
974
974
|
command: "list",
|
|
@@ -982,7 +982,7 @@ export const cli = async (args?: string[]) => {
|
|
|
982
982
|
api.log(chalk.green(p));
|
|
983
983
|
});
|
|
984
984
|
}
|
|
985
|
-
}
|
|
985
|
+
}
|
|
986
986
|
})
|
|
987
987
|
|
|
988
988
|
.command({
|
|
@@ -992,17 +992,17 @@ export const cli = async (args?: string[]) => {
|
|
|
992
992
|
yargs.positional("program", {
|
|
993
993
|
type: "string",
|
|
994
994
|
describe: "Identifier",
|
|
995
|
-
demandOption: true
|
|
995
|
+
demandOption: true
|
|
996
996
|
});
|
|
997
997
|
yargs.option("base64", {
|
|
998
998
|
type: "string",
|
|
999
999
|
describe: "Base64 encoded serialized",
|
|
1000
|
-
aliases: "b"
|
|
1000
|
+
aliases: "b"
|
|
1001
1001
|
});
|
|
1002
1002
|
yargs.option("variant", {
|
|
1003
1003
|
type: "string",
|
|
1004
1004
|
describe: "Variant name",
|
|
1005
|
-
aliases: "v"
|
|
1005
|
+
aliases: "v"
|
|
1006
1006
|
});
|
|
1007
1007
|
return yargs;
|
|
1008
1008
|
},
|
|
@@ -1015,21 +1015,20 @@ export const cli = async (args?: string[]) => {
|
|
|
1015
1015
|
let startArg: StartProgram;
|
|
1016
1016
|
if (args.base64) {
|
|
1017
1017
|
startArg = {
|
|
1018
|
-
base64: args.base64
|
|
1018
|
+
base64: args.base64
|
|
1019
1019
|
};
|
|
1020
1020
|
} else {
|
|
1021
1021
|
startArg = {
|
|
1022
|
-
variant: args.variant
|
|
1022
|
+
variant: args.variant
|
|
1023
1023
|
};
|
|
1024
1024
|
}
|
|
1025
1025
|
for (const api of apis) {
|
|
1026
|
-
const address =
|
|
1027
|
-
startArg
|
|
1028
|
-
);
|
|
1026
|
+
const address =
|
|
1027
|
+
await api.api.program.open(startArg);
|
|
1029
1028
|
api.log("Started program with address: ");
|
|
1030
1029
|
api.log(chalk.green(address.toString()));
|
|
1031
1030
|
}
|
|
1032
|
-
}
|
|
1031
|
+
}
|
|
1033
1032
|
})
|
|
1034
1033
|
.strict()
|
|
1035
1034
|
.demandCommand();
|
|
@@ -1043,7 +1042,7 @@ export const cli = async (args?: string[]) => {
|
|
|
1043
1042
|
type: "string",
|
|
1044
1043
|
describe:
|
|
1045
1044
|
"Installed dependency will be loaded with js import(...)",
|
|
1046
|
-
demandOption: true
|
|
1045
|
+
demandOption: true
|
|
1047
1046
|
});
|
|
1048
1047
|
|
|
1049
1048
|
return yargs;
|
|
@@ -1063,16 +1062,15 @@ export const cli = async (args?: string[]) => {
|
|
|
1063
1062
|
installCommand = {
|
|
1064
1063
|
type: "tgz",
|
|
1065
1064
|
name: await getPackageName(packageName),
|
|
1066
|
-
base64
|
|
1065
|
+
base64
|
|
1067
1066
|
};
|
|
1068
1067
|
} else {
|
|
1069
1068
|
installCommand = { type: "npm", name: packageName };
|
|
1070
1069
|
}
|
|
1071
1070
|
|
|
1072
1071
|
for (const api of apis) {
|
|
1073
|
-
const newPrograms =
|
|
1074
|
-
installCommand
|
|
1075
|
-
);
|
|
1072
|
+
const newPrograms =
|
|
1073
|
+
await api.api.dependency.install(installCommand);
|
|
1076
1074
|
api.log(
|
|
1077
1075
|
`New programs available (${newPrograms.length}):`
|
|
1078
1076
|
);
|
|
@@ -1080,7 +1078,7 @@ export const cli = async (args?: string[]) => {
|
|
|
1080
1078
|
api.log(chalk.green(p));
|
|
1081
1079
|
});
|
|
1082
1080
|
}
|
|
1083
|
-
}
|
|
1081
|
+
}
|
|
1084
1082
|
})
|
|
1085
1083
|
.command({
|
|
1086
1084
|
command: "restart",
|
|
@@ -1089,7 +1087,7 @@ export const cli = async (args?: string[]) => {
|
|
|
1089
1087
|
for (const api of apis) {
|
|
1090
1088
|
await api.api.restart();
|
|
1091
1089
|
}
|
|
1092
|
-
}
|
|
1090
|
+
}
|
|
1093
1091
|
})
|
|
1094
1092
|
.command({
|
|
1095
1093
|
command: "stop",
|
|
@@ -1098,7 +1096,7 @@ export const cli = async (args?: string[]) => {
|
|
|
1098
1096
|
for (const api of apis) {
|
|
1099
1097
|
await api.api.stop();
|
|
1100
1098
|
}
|
|
1101
|
-
}
|
|
1099
|
+
}
|
|
1102
1100
|
})
|
|
1103
1101
|
.help()
|
|
1104
1102
|
.strict()
|
|
@@ -1117,7 +1115,7 @@ export const cli = async (args?: string[]) => {
|
|
|
1117
1115
|
rl.prompt(true);
|
|
1118
1116
|
});
|
|
1119
1117
|
}
|
|
1120
|
-
}
|
|
1118
|
+
}
|
|
1121
1119
|
})
|
|
1122
1120
|
.help()
|
|
1123
1121
|
.strict()
|