@peerbit/server 5.0.33 → 5.0.34-2bc15a6
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/src/aws.browser.d.ts +1 -0
- package/dist/src/aws.browser.d.ts.map +1 -0
- package/{lib/esm → dist/src}/aws.d.ts +1 -0
- package/dist/src/aws.d.ts.map +1 -0
- package/{lib/esm → dist/src}/aws.js +43 -44
- package/dist/src/aws.js.map +1 -0
- package/dist/src/bin.d.ts +3 -0
- package/dist/src/bin.d.ts.map +1 -0
- package/{lib/esm → dist/src}/bin.js.map +1 -1
- package/{lib/esm → dist/src}/cli.d.ts +1 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/{lib/esm → dist/src}/cli.js +107 -106
- package/dist/src/cli.js.map +1 -0
- package/{lib/esm → dist/src}/client.d.ts +6 -5
- package/dist/src/client.d.ts.map +1 -0
- package/{lib/esm → dist/src}/client.js +28 -36
- package/dist/src/client.js.map +1 -0
- package/dist/src/config.browser.d.ts +1 -0
- package/dist/src/config.browser.d.ts.map +1 -0
- package/{lib/esm → dist/src}/config.d.ts +1 -0
- package/dist/src/config.d.ts.map +1 -0
- package/{lib/esm → dist/src}/config.js +6 -6
- package/dist/src/config.js.map +1 -0
- package/dist/src/docker.browser.d.ts +1 -0
- package/dist/src/docker.browser.d.ts.map +1 -0
- package/{lib/esm → dist/src}/docker.d.ts +1 -0
- package/dist/src/docker.d.ts.map +1 -0
- package/{lib/esm → dist/src}/docker.js +2 -2
- package/dist/src/docker.js.map +1 -0
- package/{lib/esm → dist/src}/domain.d.ts +1 -7
- package/dist/src/domain.d.ts.map +1 -0
- package/{lib/esm → dist/src}/domain.js +6 -13
- package/dist/src/domain.js.map +1 -0
- package/{lib/esm → dist/src}/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -0
- package/{lib/esm → dist/src}/peerbit.d.ts +2 -1
- package/dist/src/peerbit.d.ts.map +1 -0
- package/{lib/esm → dist/src}/peerbit.js +10 -9
- package/dist/src/peerbit.js.map +1 -0
- package/dist/src/remotes.browser.d.ts +1 -0
- package/dist/src/remotes.browser.d.ts.map +1 -0
- package/{lib/esm → dist/src}/remotes.d.ts +1 -0
- package/dist/src/remotes.d.ts.map +1 -0
- package/{lib/esm → dist/src}/remotes.js +1 -1
- package/{lib/esm → dist/src}/routes.d.ts +1 -0
- package/dist/src/routes.d.ts.map +1 -0
- package/dist/src/server.browser.d.ts +1 -0
- package/dist/src/server.browser.d.ts.map +1 -0
- package/{lib/esm → dist/src}/server.d.ts +2 -2
- package/dist/src/server.d.ts.map +1 -0
- package/{lib/esm → dist/src}/server.js +25 -27
- package/dist/src/server.js.map +1 -0
- package/{lib/esm → dist/src}/session.d.ts +2 -2
- package/dist/src/session.d.ts.map +1 -0
- package/{lib/esm → dist/src}/session.js +2 -2
- package/{lib/esm/signes-request.d.ts → dist/src/signed-request.d.ts} +3 -3
- package/dist/src/signed-request.d.ts.map +1 -0
- package/{lib/esm/signes-request.js → dist/src/signed-request.js} +3 -3
- package/{lib/esm/signes-request.js.map → dist/src/signed-request.js.map} +1 -1
- package/dist/src/trust.browser.d.ts +1 -0
- package/dist/src/trust.browser.d.ts.map +1 -0
- package/{lib/esm → dist/src}/trust.d.ts +1 -0
- package/dist/src/trust.d.ts.map +1 -0
- package/{lib/esm → dist/src}/types.d.ts +1 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/test/api.spec.d.ts +2 -0
- package/dist/test/api.spec.d.ts.map +1 -0
- package/dist/test/api.spec.js +223 -0
- package/dist/test/api.spec.js.map +1 -0
- package/dist/test/cli.spec.d.ts +2 -0
- package/dist/test/cli.spec.d.ts.map +1 -0
- package/dist/test/cli.spec.js +264 -0
- package/dist/test/cli.spec.js.map +1 -0
- package/dist/test/client.spec.d.ts +2 -0
- package/dist/test/client.spec.d.ts.map +1 -0
- package/dist/test/client.spec.js +23 -0
- package/dist/test/client.spec.js.map +1 -0
- package/dist/test/config.spec.d.ts +2 -0
- package/dist/test/config.spec.d.ts.map +1 -0
- package/dist/test/config.spec.js +12 -0
- package/dist/test/config.spec.js.map +1 -0
- package/dist/test/domain.integration.spec.d.ts +2 -0
- package/dist/test/domain.integration.spec.d.ts.map +1 -0
- package/dist/test/domain.integration.spec.js +101 -0
- package/dist/test/domain.integration.spec.js.map +1 -0
- package/dist/test/launch.spec.d.ts +1 -0
- package/dist/test/launch.spec.d.ts.map +1 -0
- package/dist/test/launch.spec.js +23 -0
- package/dist/test/launch.spec.js.map +1 -0
- package/dist/test/signed-request.spec.d.ts +2 -0
- package/dist/test/signed-request.spec.d.ts.map +1 -0
- package/dist/test/signed-request.spec.js +35 -0
- package/dist/test/signed-request.spec.js.map +1 -0
- package/dist/test/utils.d.ts +3 -0
- package/dist/test/utils.d.ts.map +1 -0
- package/dist/test/utils.js +6 -0
- package/dist/test/utils.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/ui/assets/index-fCy8gbsO.js +128 -0
- package/dist/ui/assets/index-q5H34Jar.js +6 -0
- package/{lib → dist}/ui/index.html +3 -3
- package/package.json +90 -78
- package/src/aws.ts +57 -58
- package/src/bin.ts +1 -0
- package/src/cli.ts +149 -146
- package/src/client.ts +66 -81
- package/src/config.ts +12 -12
- package/src/docker.ts +3 -3
- package/src/domain.ts +16 -23
- package/src/peerbit.ts +10 -10
- package/src/remotes.ts +2 -2
- package/src/server.ts +58 -68
- package/src/session.ts +7 -7
- package/src/{signes-request.ts → signed-request.ts} +8 -8
- package/src/trust.ts +1 -1
- package/lib/esm/aws.browser.d.ts +0 -0
- package/lib/esm/aws.js.map +0 -1
- package/lib/esm/bin.d.ts +0 -2
- package/lib/esm/cli.js.map +0 -1
- package/lib/esm/client.js.map +0 -1
- package/lib/esm/config.browser.d.ts +0 -0
- package/lib/esm/config.js.map +0 -1
- package/lib/esm/docker.browser.d.ts +0 -0
- package/lib/esm/docker.js.map +0 -1
- package/lib/esm/domain.js.map +0 -1
- package/lib/esm/peerbit.js.map +0 -1
- package/lib/esm/remotes.browser.d.ts +0 -0
- package/lib/esm/server.browser.d.ts +0 -0
- package/lib/esm/server.js.map +0 -1
- package/lib/esm/trust.browser.d.ts +0 -0
- package/lib/ui/assets/index-BSyx7bor.js +0 -6
- package/lib/ui/assets/index-DUhlTXpa.js +0 -77
- package/lib/ui/assets/manifest-DSoGU8T2.json +0 -25
- /package/{lib/esm → dist}/nginx-template.conf +0 -0
- /package/{lib/esm → dist/src}/aws.browser.js +0 -0
- /package/{lib/esm → dist/src}/aws.browser.js.map +0 -0
- /package/{lib/esm → dist/src}/bin.js +0 -0
- /package/{lib/esm → dist/src}/config.browser.js +0 -0
- /package/{lib/esm → dist/src}/config.browser.js.map +0 -0
- /package/{lib/esm → dist/src}/docker.browser.js +0 -0
- /package/{lib/esm → dist/src}/docker.browser.js.map +0 -0
- /package/{lib/esm → dist/src}/index.js +0 -0
- /package/{lib/esm → dist/src}/index.js.map +0 -0
- /package/{lib/esm → dist/src}/remotes.browser.js +0 -0
- /package/{lib/esm → dist/src}/remotes.browser.js.map +0 -0
- /package/{lib/esm → dist/src}/remotes.js.map +0 -0
- /package/{lib/esm → dist/src}/routes.js +0 -0
- /package/{lib/esm → dist/src}/routes.js.map +0 -0
- /package/{lib/esm → dist/src}/server.browser.js +0 -0
- /package/{lib/esm → dist/src}/server.browser.js.map +0 -0
- /package/{lib/esm → dist/src}/session.js.map +0 -0
- /package/{lib/esm → dist/src}/trust.browser.js +0 -0
- /package/{lib/esm → dist/src}/trust.browser.js.map +0 -0
- /package/{lib/esm → dist/src}/trust.js +0 -0
- /package/{lib/esm → dist/src}/trust.js.map +0 -0
- /package/{lib/esm → dist/src}/types.js +0 -0
- /package/{lib/esm → dist/src}/types.js.map +0 -0
- /package/{lib → dist}/ui/android-chrome-192x192.png +0 -0
- /package/{lib → dist}/ui/android-chrome-512x512.png +0 -0
- /package/{lib → dist}/ui/assets/favicon-BYZpRdSr.ico +0 -0
- /package/{lib → dist}/ui/assets/index-BDBx6C_I.css +0 -0
- /package/{lib → dist}/ui/favicon-16x16.png +0 -0
- /package/{lib → dist}/ui/favicon-32x32.png +0 -0
- /package/{lib → dist}/ui/favicon.ico +0 -0
- /package/{lib → dist}/ui/manifest.json +0 -0
- /package/{lib → dist}/ui/robots.txt +0 -0
package/src/cli.ts
CHANGED
|
@@ -1,36 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from "
|
|
7
|
-
import
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
|
|
3
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
4
|
+
import type { PeerId } from "@libp2p/interface";
|
|
5
|
+
import { peerIdFromString } from "@libp2p/peer-id";
|
|
6
|
+
import { toBase64 } from "@peerbit/crypto";
|
|
7
|
+
import chalk from "chalk";
|
|
8
|
+
import fs from "fs";
|
|
9
|
+
import path from "path";
|
|
10
|
+
import { exit } from "process";
|
|
11
|
+
import readline from "readline";
|
|
12
|
+
import Table from "tty-table";
|
|
13
|
+
import type yargs from "yargs";
|
|
8
14
|
import {
|
|
9
15
|
AWS_LINUX_ARM_AMIs,
|
|
10
16
|
createRecord,
|
|
11
17
|
launchNodes,
|
|
12
|
-
terminateNode
|
|
18
|
+
terminateNode,
|
|
13
19
|
} from "./aws.js";
|
|
20
|
+
import { createClient, waitForDomain } from "./client.js";
|
|
14
21
|
import {
|
|
15
22
|
getHomeConfigDir,
|
|
16
23
|
getKeypair,
|
|
17
24
|
getPackageName,
|
|
18
|
-
getRemotesPath
|
|
25
|
+
getRemotesPath,
|
|
19
26
|
} from "./config.js";
|
|
20
|
-
import
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
import
|
|
27
|
-
import path from "path";
|
|
28
|
-
import { toBase64 } from "@peerbit/crypto";
|
|
29
|
-
import { DEFAULT_REMOTE_GROUP, RemoteObject, Remotes } from "./remotes.js";
|
|
30
|
-
import { peerIdFromString } from "@libp2p/peer-id";
|
|
27
|
+
import {
|
|
28
|
+
createTestDomain,
|
|
29
|
+
getDomainFromConfig,
|
|
30
|
+
loadConfig,
|
|
31
|
+
startCertbot,
|
|
32
|
+
} from "./domain.js";
|
|
33
|
+
import { DEFAULT_REMOTE_GROUP, type RemoteObject, Remotes } from "./remotes.js";
|
|
31
34
|
import { LOCAL_API_PORT } from "./routes.js";
|
|
32
|
-
import {
|
|
33
|
-
import
|
|
35
|
+
import { startServerWithNode } from "./server.js";
|
|
36
|
+
import type { InstallDependency, StartProgram } from "./types.js";
|
|
34
37
|
|
|
35
38
|
const colors = [
|
|
36
39
|
"#00FF00",
|
|
@@ -95,13 +98,13 @@ const colors = [
|
|
|
95
98
|
"#A5FFD2",
|
|
96
99
|
"#FFB167",
|
|
97
100
|
"#009BFF",
|
|
98
|
-
"#E85EBE"
|
|
101
|
+
"#E85EBE",
|
|
99
102
|
];
|
|
100
103
|
const padString = function (
|
|
101
104
|
string: string,
|
|
102
105
|
padding: number,
|
|
103
106
|
padChar = " ",
|
|
104
|
-
stringLength = string.valueOf().length
|
|
107
|
+
stringLength = string.valueOf().length,
|
|
105
108
|
) {
|
|
106
109
|
const val = string.valueOf();
|
|
107
110
|
if (Math.abs(padding) <= stringLength) {
|
|
@@ -135,12 +138,12 @@ export const cli = async (args?: string[]) => {
|
|
|
135
138
|
defaultDescription: "~.peerbit",
|
|
136
139
|
type: "string",
|
|
137
140
|
alias: "d",
|
|
138
|
-
default: getHomeConfigDir()
|
|
141
|
+
default: getHomeConfigDir(),
|
|
139
142
|
})
|
|
140
143
|
.option("bootstrap", {
|
|
141
144
|
describe: "Whether to connect to bootstap nodes on startup",
|
|
142
145
|
type: "boolean",
|
|
143
|
-
default: false
|
|
146
|
+
default: false,
|
|
144
147
|
})
|
|
145
148
|
.option("grant-access", {
|
|
146
149
|
describe: "Grant access to public keys on start",
|
|
@@ -148,26 +151,26 @@ export const cli = async (args?: string[]) => {
|
|
|
148
151
|
"The publickey of this device located in 'directory'",
|
|
149
152
|
type: "string",
|
|
150
153
|
array: true,
|
|
151
|
-
alias: "ga"
|
|
154
|
+
alias: "ga",
|
|
152
155
|
})
|
|
153
156
|
.option("reset", {
|
|
154
157
|
describe:
|
|
155
158
|
"If true, then programs opened during last session will not be opened",
|
|
156
159
|
type: "boolean",
|
|
157
160
|
default: false,
|
|
158
|
-
alias: "r"
|
|
161
|
+
alias: "r",
|
|
159
162
|
})
|
|
160
163
|
.option("port-api", {
|
|
161
164
|
describe:
|
|
162
165
|
"Set API server port. Only modify this when testing locally, since NGINX config depends on the default value",
|
|
163
166
|
type: "number",
|
|
164
|
-
default: undefined
|
|
167
|
+
default: undefined,
|
|
165
168
|
})
|
|
166
169
|
.option("port-node", {
|
|
167
170
|
describe:
|
|
168
171
|
"Set Libp2p listen port. Only modify this when testing locally, since NGINX config depends on the default value",
|
|
169
172
|
type: "number",
|
|
170
|
-
default: undefined
|
|
173
|
+
default: undefined,
|
|
171
174
|
});
|
|
172
175
|
return yargs;
|
|
173
176
|
},
|
|
@@ -175,14 +178,14 @@ export const cli = async (args?: string[]) => {
|
|
|
175
178
|
await startServerWithNode({
|
|
176
179
|
directory: args.directory,
|
|
177
180
|
domain: await loadConfig().then((config) =>
|
|
178
|
-
config ? getDomainFromConfig(config) : undefined
|
|
181
|
+
config ? getDomainFromConfig(config) : undefined,
|
|
179
182
|
),
|
|
180
183
|
ports: { api: args["port-api"], node: args["port-node"] },
|
|
181
184
|
bootstrap: args.bootstrap,
|
|
182
185
|
newSession: args.reset,
|
|
183
|
-
grantAccess: args["grant-access"]
|
|
186
|
+
grantAccess: args["grant-access"],
|
|
184
187
|
});
|
|
185
|
-
}
|
|
188
|
+
},
|
|
186
189
|
})
|
|
187
190
|
.command({
|
|
188
191
|
command: "id",
|
|
@@ -193,14 +196,14 @@ export const cli = async (args?: string[]) => {
|
|
|
193
196
|
defaultDescription: "~.peerbit",
|
|
194
197
|
type: "string",
|
|
195
198
|
alias: "d",
|
|
196
|
-
default: getHomeConfigDir()
|
|
199
|
+
default: getHomeConfigDir(),
|
|
197
200
|
});
|
|
198
201
|
return yargs;
|
|
199
202
|
},
|
|
200
203
|
handler: async (args) => {
|
|
201
204
|
const kp = await getKeypair(args.directory);
|
|
202
205
|
console.log((await kp.toPeerId()).toString());
|
|
203
|
-
}
|
|
206
|
+
},
|
|
204
207
|
})
|
|
205
208
|
.command(
|
|
206
209
|
"domain",
|
|
@@ -215,25 +218,25 @@ export const cli = async (args?: string[]) => {
|
|
|
215
218
|
email: {
|
|
216
219
|
describe: "Email for Lets encrypt autorenewal messages",
|
|
217
220
|
type: "string",
|
|
218
|
-
demandOption: true
|
|
221
|
+
demandOption: true,
|
|
219
222
|
},
|
|
220
223
|
outdir: {
|
|
221
224
|
describe: "Output path for Nginx config",
|
|
222
225
|
type: "string",
|
|
223
|
-
alias: "o"
|
|
226
|
+
alias: "o",
|
|
224
227
|
},
|
|
225
228
|
wait: {
|
|
226
229
|
alias: "w",
|
|
227
230
|
describe: "Wait for setup to succeed (or fail)",
|
|
228
231
|
type: "boolean",
|
|
229
|
-
default: false
|
|
230
|
-
}
|
|
232
|
+
default: false,
|
|
233
|
+
},
|
|
231
234
|
},
|
|
232
235
|
handler: async (args) => {
|
|
233
236
|
const domain = await createTestDomain();
|
|
234
237
|
await startCertbot(domain, args.email, args.outdir, args.wait);
|
|
235
238
|
exit();
|
|
236
|
-
}
|
|
239
|
+
},
|
|
237
240
|
})
|
|
238
241
|
.command({
|
|
239
242
|
command: "aws",
|
|
@@ -244,45 +247,45 @@ export const cli = async (args?: string[]) => {
|
|
|
244
247
|
describe: "domain, e.g. abc.example.com, example.com",
|
|
245
248
|
alias: "d",
|
|
246
249
|
type: "string",
|
|
247
|
-
demandOption: true
|
|
250
|
+
demandOption: true,
|
|
248
251
|
},
|
|
249
252
|
hostedZoneId: {
|
|
250
253
|
describe: 'The id of the hosted zone "HostedZoneId"',
|
|
251
254
|
alias: "hz",
|
|
252
255
|
type: "string",
|
|
253
|
-
require: true
|
|
256
|
+
require: true,
|
|
254
257
|
},
|
|
255
258
|
accessKeyId: {
|
|
256
259
|
describe: "Access key id of the AWS user",
|
|
257
260
|
alias: "ak",
|
|
258
|
-
type: "string"
|
|
261
|
+
type: "string",
|
|
259
262
|
},
|
|
260
263
|
region: {
|
|
261
264
|
describe: "AWS region",
|
|
262
265
|
alias: "r",
|
|
263
|
-
type: "string"
|
|
266
|
+
type: "string",
|
|
264
267
|
},
|
|
265
268
|
secretAccessKey: {
|
|
266
269
|
describe: "Secret key id of the AWS user",
|
|
267
270
|
alias: "sk",
|
|
268
|
-
type: "string"
|
|
271
|
+
type: "string",
|
|
269
272
|
},
|
|
270
273
|
email: {
|
|
271
274
|
describe: "Email for Lets encrypt auto-renewal messages",
|
|
272
275
|
type: "string",
|
|
273
|
-
demandOption: true
|
|
276
|
+
demandOption: true,
|
|
274
277
|
},
|
|
275
278
|
outdir: {
|
|
276
279
|
describe: "Output path for Nginx config",
|
|
277
280
|
type: "string",
|
|
278
|
-
alias: "o"
|
|
281
|
+
alias: "o",
|
|
279
282
|
},
|
|
280
283
|
wait: {
|
|
281
284
|
alias: "w",
|
|
282
285
|
describe: "Wait for setup to succeed (or fail)",
|
|
283
286
|
type: "boolean",
|
|
284
|
-
default: false
|
|
285
|
-
}
|
|
287
|
+
default: false,
|
|
288
|
+
},
|
|
286
289
|
},
|
|
287
290
|
handler: async (args) => {
|
|
288
291
|
if (
|
|
@@ -290,7 +293,7 @@ export const cli = async (args?: string[]) => {
|
|
|
290
293
|
!!args.region !== !!args.secretAccessKey
|
|
291
294
|
) {
|
|
292
295
|
throw new Error(
|
|
293
|
-
"Expecting either all 'accessKeyId', 'region' and 'secretAccessKey' to be provided or none"
|
|
296
|
+
"Expecting either all 'accessKeyId', 'region' and 'secretAccessKey' to be provided or none",
|
|
294
297
|
);
|
|
295
298
|
}
|
|
296
299
|
await createRecord({
|
|
@@ -300,22 +303,22 @@ export const cli = async (args?: string[]) => {
|
|
|
300
303
|
credentials: args.accessKeyId
|
|
301
304
|
? {
|
|
302
305
|
accessKeyId: args.accessKeyId,
|
|
303
|
-
secretAccessKey: args.secretAccessKey
|
|
306
|
+
secretAccessKey: args.secretAccessKey,
|
|
304
307
|
}
|
|
305
|
-
: undefined
|
|
308
|
+
: undefined,
|
|
306
309
|
});
|
|
307
310
|
await startCertbot(
|
|
308
311
|
args.domain,
|
|
309
312
|
args.email,
|
|
310
313
|
args.outdir,
|
|
311
|
-
args.wait
|
|
314
|
+
args.wait,
|
|
312
315
|
);
|
|
313
316
|
exit();
|
|
314
|
-
}
|
|
317
|
+
},
|
|
315
318
|
})
|
|
316
319
|
.strict()
|
|
317
320
|
.demandCommand();
|
|
318
|
-
}
|
|
321
|
+
},
|
|
319
322
|
)
|
|
320
323
|
.command("remote", "Handle remote nodes", (innerYargs) => {
|
|
321
324
|
innerYargs
|
|
@@ -330,19 +333,19 @@ export const cli = async (args?: string[]) => {
|
|
|
330
333
|
defaultDescription: "One node",
|
|
331
334
|
type: "number",
|
|
332
335
|
alias: "c",
|
|
333
|
-
default: 1
|
|
336
|
+
default: 1,
|
|
334
337
|
});
|
|
335
338
|
awsArgs.option("region", {
|
|
336
339
|
describe: "Region",
|
|
337
340
|
type: "string",
|
|
338
341
|
defaultDescription: "Region defined in ~.aws/config",
|
|
339
|
-
choices: Object.keys(AWS_LINUX_ARM_AMIs)
|
|
342
|
+
choices: Object.keys(AWS_LINUX_ARM_AMIs),
|
|
340
343
|
});
|
|
341
344
|
awsArgs.option("group", {
|
|
342
345
|
describe: "Remote group to launch nodes in",
|
|
343
346
|
type: "string",
|
|
344
347
|
alias: "g",
|
|
345
|
-
default: DEFAULT_REMOTE_GROUP
|
|
348
|
+
default: DEFAULT_REMOTE_GROUP,
|
|
346
349
|
});
|
|
347
350
|
awsArgs.option("size", {
|
|
348
351
|
describe: "Instance size",
|
|
@@ -354,16 +357,16 @@ export const cli = async (args?: string[]) => {
|
|
|
354
357
|
"medium",
|
|
355
358
|
"large",
|
|
356
359
|
"xlarge",
|
|
357
|
-
"2xlarge"
|
|
360
|
+
"2xlarge",
|
|
358
361
|
],
|
|
359
|
-
default: "micro"
|
|
362
|
+
default: "micro",
|
|
360
363
|
});
|
|
361
364
|
|
|
362
365
|
awsArgs.option("name", {
|
|
363
366
|
describe: "Name prefix for spawned nodes",
|
|
364
367
|
type: "string",
|
|
365
368
|
alias: "n",
|
|
366
|
-
default: "peerbit-node"
|
|
369
|
+
default: "peerbit-node",
|
|
367
370
|
});
|
|
368
371
|
awsArgs.option("grant-access", {
|
|
369
372
|
describe: "Grant access to public keys on start",
|
|
@@ -371,25 +374,25 @@ export const cli = async (args?: string[]) => {
|
|
|
371
374
|
"The publickey of this device located in 'directory'",
|
|
372
375
|
type: "string",
|
|
373
376
|
array: true,
|
|
374
|
-
alias: "ga"
|
|
377
|
+
alias: "ga",
|
|
375
378
|
});
|
|
376
379
|
awsArgs.option("directory", {
|
|
377
380
|
describe: "Peerbit directory",
|
|
378
381
|
defaultDescription: "~.peerbit",
|
|
379
382
|
type: "string",
|
|
380
383
|
alias: "d",
|
|
381
|
-
default: getHomeConfigDir()
|
|
384
|
+
default: getHomeConfigDir(),
|
|
382
385
|
});
|
|
383
386
|
return awsArgs;
|
|
384
387
|
},
|
|
385
388
|
handler: async (args) => {
|
|
386
389
|
const accessGrant: PeerId[] =
|
|
387
390
|
args.access?.length > 0
|
|
388
|
-
? args.access.map((x) => peerIdFromString(x))
|
|
391
|
+
? args.access.map((x: any) => peerIdFromString(x))
|
|
389
392
|
: [
|
|
390
393
|
await (
|
|
391
394
|
await getKeypair(args.directory)
|
|
392
|
-
).publicKey.toPeerId()
|
|
395
|
+
).publicKey.toPeerId(),
|
|
393
396
|
];
|
|
394
397
|
const nodes = await launchNodes({
|
|
395
398
|
email: "marcus@dao.xyz",
|
|
@@ -397,20 +400,20 @@ export const cli = async (args?: string[]) => {
|
|
|
397
400
|
namePrefix: args.name,
|
|
398
401
|
region: args.region,
|
|
399
402
|
grantAccess: accessGrant,
|
|
400
|
-
size: args.size
|
|
403
|
+
size: args.size,
|
|
401
404
|
});
|
|
402
405
|
|
|
403
406
|
console.log(
|
|
404
407
|
`Waiting for ${args.count} ${
|
|
405
408
|
args.count > 1 ? "nodes" : "node"
|
|
406
|
-
} to spawn. This might take a few minutes. You can watch the progress in your AWS console
|
|
409
|
+
} to spawn. This might take a few minutes. You can watch the progress in your AWS console.`,
|
|
407
410
|
);
|
|
408
411
|
const twirlTimer = (function () {
|
|
409
412
|
const P = ["\\", "|", "/", "-"];
|
|
410
413
|
let x = 0;
|
|
411
414
|
return setInterval(function () {
|
|
412
415
|
process.stdout.write(
|
|
413
|
-
"\r" + "Loading: " + chalk.hex(colors[x])(P[x++])
|
|
416
|
+
"\r" + "Loading: " + chalk.hex(colors[x])(P[x++]),
|
|
414
417
|
);
|
|
415
418
|
x &= 3;
|
|
416
419
|
}, 250);
|
|
@@ -426,15 +429,15 @@ export const cli = async (args?: string[]) => {
|
|
|
426
429
|
origin: {
|
|
427
430
|
type: "aws",
|
|
428
431
|
instanceId: node.instanceId,
|
|
429
|
-
region: node.region
|
|
430
|
-
}
|
|
432
|
+
region: node.region,
|
|
433
|
+
},
|
|
431
434
|
});
|
|
432
435
|
} catch (error: any) {
|
|
433
436
|
process.stdout.write("\r");
|
|
434
437
|
console.error(
|
|
435
438
|
`Error waiting for domain for ip: ${
|
|
436
439
|
node.publicIp
|
|
437
|
-
} to be available: ${error?.toString()}
|
|
440
|
+
} to be available: ${error?.toString()}`,
|
|
438
441
|
);
|
|
439
442
|
}
|
|
440
443
|
}
|
|
@@ -444,7 +447,7 @@ export const cli = async (args?: string[]) => {
|
|
|
444
447
|
for (const node of nodes) {
|
|
445
448
|
console.log(chalk.green(node.name));
|
|
446
449
|
}
|
|
447
|
-
}
|
|
450
|
+
},
|
|
448
451
|
})
|
|
449
452
|
.strict()
|
|
450
453
|
.demandCommand();
|
|
@@ -456,21 +459,21 @@ export const cli = async (args?: string[]) => {
|
|
|
456
459
|
killArgs.option("all", {
|
|
457
460
|
describe: "Kill all nodes",
|
|
458
461
|
type: "boolean",
|
|
459
|
-
default: false
|
|
462
|
+
default: false,
|
|
460
463
|
});
|
|
461
464
|
killArgs.positional("name", {
|
|
462
465
|
type: "string",
|
|
463
466
|
describe: "Remote name",
|
|
464
467
|
default: "localhost",
|
|
465
468
|
demandOption: false,
|
|
466
|
-
array: true
|
|
469
|
+
array: true,
|
|
467
470
|
});
|
|
468
471
|
killArgs.option("directory", {
|
|
469
472
|
describe: "Peerbit directory",
|
|
470
473
|
defaultDescription: "~.peerbit",
|
|
471
474
|
type: "string",
|
|
472
475
|
alias: "d",
|
|
473
|
-
default: getHomeConfigDir()
|
|
476
|
+
default: getHomeConfigDir(),
|
|
474
477
|
});
|
|
475
478
|
return killArgs;
|
|
476
479
|
},
|
|
@@ -482,12 +485,12 @@ export const cli = async (args?: string[]) => {
|
|
|
482
485
|
if (remote.origin?.type === "aws") {
|
|
483
486
|
await terminateNode({
|
|
484
487
|
instanceId: remote.origin.instanceId,
|
|
485
|
-
region: remote.origin.region
|
|
488
|
+
region: remote.origin.region,
|
|
486
489
|
});
|
|
487
490
|
}
|
|
488
491
|
}
|
|
489
492
|
}
|
|
490
|
-
}
|
|
493
|
+
},
|
|
491
494
|
})
|
|
492
495
|
.command({
|
|
493
496
|
command: "list",
|
|
@@ -499,7 +502,7 @@ export const cli = async (args?: string[]) => {
|
|
|
499
502
|
defaultDescription: "~.peerbit",
|
|
500
503
|
type: "string",
|
|
501
504
|
alias: "d",
|
|
502
|
-
default: getHomeConfigDir()
|
|
505
|
+
default: getHomeConfigDir(),
|
|
503
506
|
});
|
|
504
507
|
|
|
505
508
|
return yargs;
|
|
@@ -511,11 +514,11 @@ export const cli = async (args?: string[]) => {
|
|
|
511
514
|
const all = allRemotes;
|
|
512
515
|
const apis = await Promise.all(
|
|
513
516
|
all.map(async (remote) =>
|
|
514
|
-
createClient(await getKeypair(args.directory), remote)
|
|
515
|
-
)
|
|
517
|
+
createClient(await getKeypair(args.directory), remote),
|
|
518
|
+
),
|
|
516
519
|
);
|
|
517
520
|
const resolvedOrRejected = await Promise.allSettled(
|
|
518
|
-
apis.map((x) => x.peer.id.get())
|
|
521
|
+
apis.map((x) => x.peer.id.get()),
|
|
519
522
|
);
|
|
520
523
|
|
|
521
524
|
if (all.length > 0) {
|
|
@@ -530,7 +533,7 @@ export const cli = async (args?: string[]) => {
|
|
|
530
533
|
resolvedOrRejected[ix].status === "fulfilled"
|
|
531
534
|
? chalk.green("Y")
|
|
532
535
|
: chalk.red("N"),
|
|
533
|
-
remote.address
|
|
536
|
+
remote.address,
|
|
534
537
|
];
|
|
535
538
|
rows.push(row);
|
|
536
539
|
}
|
|
@@ -538,13 +541,13 @@ export const cli = async (args?: string[]) => {
|
|
|
538
541
|
["Name", "Group", "Origin", "Online", "Address"].map((x) => {
|
|
539
542
|
return { value: x, align: "left" };
|
|
540
543
|
}),
|
|
541
|
-
rows
|
|
544
|
+
rows,
|
|
542
545
|
);
|
|
543
546
|
console.log(table.render());
|
|
544
547
|
} else {
|
|
545
548
|
console.log("No remotes found!");
|
|
546
549
|
}
|
|
547
|
-
}
|
|
550
|
+
},
|
|
548
551
|
})
|
|
549
552
|
.command({
|
|
550
553
|
command: "add <name> <address>",
|
|
@@ -554,25 +557,25 @@ export const cli = async (args?: string[]) => {
|
|
|
554
557
|
.positional("name", {
|
|
555
558
|
type: "string",
|
|
556
559
|
describe: "Remote address",
|
|
557
|
-
demandOption: true
|
|
560
|
+
demandOption: true,
|
|
558
561
|
})
|
|
559
562
|
.positional("address", {
|
|
560
563
|
type: "string",
|
|
561
564
|
describe: "Remote name",
|
|
562
|
-
demandOption: true
|
|
565
|
+
demandOption: true,
|
|
563
566
|
})
|
|
564
567
|
.option("group", {
|
|
565
568
|
describe: "Group name",
|
|
566
569
|
type: "string",
|
|
567
570
|
alias: "g",
|
|
568
|
-
default: DEFAULT_REMOTE_GROUP
|
|
571
|
+
default: DEFAULT_REMOTE_GROUP,
|
|
569
572
|
})
|
|
570
573
|
.option("directory", {
|
|
571
574
|
describe: "Peerbit directory",
|
|
572
575
|
defaultDescription: "~.peerbit",
|
|
573
576
|
type: "string",
|
|
574
577
|
alias: "d",
|
|
575
|
-
default: getHomeConfigDir()
|
|
578
|
+
default: getHomeConfigDir(),
|
|
576
579
|
});
|
|
577
580
|
|
|
578
581
|
return yargs;
|
|
@@ -582,7 +585,7 @@ export const cli = async (args?: string[]) => {
|
|
|
582
585
|
throw new Error("Remote can not be named 'localhost'");
|
|
583
586
|
}
|
|
584
587
|
const api = await createClient(await getKeypair(args.directory), {
|
|
585
|
-
address: args.address
|
|
588
|
+
address: args.address,
|
|
586
589
|
});
|
|
587
590
|
try {
|
|
588
591
|
await api.program.list();
|
|
@@ -596,9 +599,9 @@ export const cli = async (args?: string[]) => {
|
|
|
596
599
|
remotes.add({
|
|
597
600
|
name: args.name,
|
|
598
601
|
address: args.address,
|
|
599
|
-
group: args.group
|
|
602
|
+
group: args.group,
|
|
600
603
|
});
|
|
601
|
-
}
|
|
604
|
+
},
|
|
602
605
|
})
|
|
603
606
|
.command({
|
|
604
607
|
command: "remove <name>",
|
|
@@ -609,14 +612,14 @@ export const cli = async (args?: string[]) => {
|
|
|
609
612
|
.positional("name", {
|
|
610
613
|
type: "string",
|
|
611
614
|
describe: "Remote address",
|
|
612
|
-
demandOption: true
|
|
615
|
+
demandOption: true,
|
|
613
616
|
})
|
|
614
617
|
.option("directory", {
|
|
615
618
|
describe: "Peerbit directory",
|
|
616
619
|
defaultDescription: "~.peerbit",
|
|
617
620
|
type: "string",
|
|
618
621
|
alias: "d",
|
|
619
|
-
default: getHomeConfigDir()
|
|
622
|
+
default: getHomeConfigDir(),
|
|
620
623
|
});
|
|
621
624
|
|
|
622
625
|
return yargs;
|
|
@@ -625,15 +628,15 @@ export const cli = async (args?: string[]) => {
|
|
|
625
628
|
const remotes = new Remotes(getRemotesPath(args.directory));
|
|
626
629
|
if (remotes.remove(args.name)) {
|
|
627
630
|
console.log(
|
|
628
|
-
chalk.green("Removed remote with name: " + args.name)
|
|
631
|
+
chalk.green("Removed remote with name: " + args.name),
|
|
629
632
|
);
|
|
630
633
|
remotes.save();
|
|
631
634
|
} else {
|
|
632
635
|
console.log(
|
|
633
|
-
chalk.red("Did not find any remote with name: " + args.name)
|
|
636
|
+
chalk.red("Did not find any remote with name: " + args.name),
|
|
634
637
|
);
|
|
635
638
|
}
|
|
636
|
-
}
|
|
639
|
+
},
|
|
637
640
|
})
|
|
638
641
|
.command({
|
|
639
642
|
command: "connect [name...]",
|
|
@@ -645,26 +648,26 @@ export const cli = async (args?: string[]) => {
|
|
|
645
648
|
describe: "Remote name",
|
|
646
649
|
default: "localhost",
|
|
647
650
|
demandOption: false,
|
|
648
|
-
array: true
|
|
651
|
+
array: true,
|
|
649
652
|
})
|
|
650
653
|
.option("all", {
|
|
651
654
|
type: "boolean",
|
|
652
655
|
describe: "Connect to all nodes",
|
|
653
|
-
default: false
|
|
656
|
+
default: false,
|
|
654
657
|
})
|
|
655
658
|
.option("group", {
|
|
656
659
|
type: "string",
|
|
657
660
|
describe: "Remote group name",
|
|
658
661
|
alias: "g",
|
|
659
662
|
default: [],
|
|
660
|
-
array: true
|
|
663
|
+
array: true,
|
|
661
664
|
})
|
|
662
665
|
.option("directory", {
|
|
663
666
|
describe: "Peerbit directory",
|
|
664
667
|
defaultDescription: "~.peerbit",
|
|
665
668
|
type: "string",
|
|
666
669
|
alias: "d",
|
|
667
|
-
default: getHomeConfigDir()
|
|
670
|
+
default: getHomeConfigDir(),
|
|
668
671
|
});
|
|
669
672
|
return yargs;
|
|
670
673
|
},
|
|
@@ -690,12 +693,12 @@ export const cli = async (args?: string[]) => {
|
|
|
690
693
|
|
|
691
694
|
const selectedRemotes: RemoteObject[] = [];
|
|
692
695
|
if (names.length > 0) {
|
|
693
|
-
for (const [
|
|
696
|
+
for (const [_ix, name] of names.entries()) {
|
|
694
697
|
if (name === "localhost") {
|
|
695
698
|
selectedRemotes.push({
|
|
696
699
|
address: "http://localhost:" + LOCAL_API_PORT,
|
|
697
700
|
name: "localhost",
|
|
698
|
-
group: DEFAULT_REMOTE_GROUP
|
|
701
|
+
group: DEFAULT_REMOTE_GROUP,
|
|
699
702
|
});
|
|
700
703
|
} else {
|
|
701
704
|
const remote = remotes.getByName(name);
|
|
@@ -724,7 +727,7 @@ export const cli = async (args?: string[]) => {
|
|
|
724
727
|
|
|
725
728
|
if (selectedRemotes.length === 0) {
|
|
726
729
|
console.log(
|
|
727
|
-
chalk.red("No remotes matched your connection condition")
|
|
730
|
+
chalk.red("No remotes matched your connection condition"),
|
|
728
731
|
);
|
|
729
732
|
} else {
|
|
730
733
|
console.log(`Connected to (${selectedRemotes.length}):`);
|
|
@@ -738,16 +741,16 @@ export const cli = async (args?: string[]) => {
|
|
|
738
741
|
chalkBg(remote.name),
|
|
739
742
|
maxNameLength,
|
|
740
743
|
" ",
|
|
741
|
-
remote.name.length
|
|
744
|
+
remote.name.length,
|
|
742
745
|
) +
|
|
743
746
|
": " +
|
|
744
|
-
string
|
|
747
|
+
string,
|
|
745
748
|
);
|
|
746
749
|
|
|
747
750
|
apis.push({
|
|
748
751
|
log: logFn,
|
|
749
752
|
name: remote.name,
|
|
750
|
-
api: await createClient(keypair, remote)
|
|
753
|
+
api: await createClient(keypair, remote),
|
|
751
754
|
});
|
|
752
755
|
}
|
|
753
756
|
|
|
@@ -757,7 +760,7 @@ export const cli = async (args?: string[]) => {
|
|
|
757
760
|
await api.api.program.list();
|
|
758
761
|
} catch (error) {
|
|
759
762
|
throw new Error(
|
|
760
|
-
`Failed to connect to '${api.name}': ${error?.toString()}
|
|
763
|
+
`Failed to connect to '${api.name}': ${error?.toString()}`,
|
|
761
764
|
);
|
|
762
765
|
}
|
|
763
766
|
}
|
|
@@ -766,7 +769,7 @@ export const cli = async (args?: string[]) => {
|
|
|
766
769
|
input: process.stdin,
|
|
767
770
|
output: process.stdout,
|
|
768
771
|
terminal: true,
|
|
769
|
-
historySize: 100
|
|
772
|
+
historySize: 100,
|
|
770
773
|
});
|
|
771
774
|
|
|
772
775
|
console.log("Write 'help' to show commands.\n");
|
|
@@ -783,7 +786,7 @@ export const cli = async (args?: string[]) => {
|
|
|
783
786
|
for (const api of apis) {
|
|
784
787
|
api.log((await api.api.peer.id.get()).toString());
|
|
785
788
|
}
|
|
786
|
-
}
|
|
789
|
+
},
|
|
787
790
|
})
|
|
788
791
|
.command({
|
|
789
792
|
command: "address",
|
|
@@ -791,10 +794,10 @@ export const cli = async (args?: string[]) => {
|
|
|
791
794
|
handler: async (args) => {
|
|
792
795
|
for (const api of apis) {
|
|
793
796
|
(await api.api.peer.addresses.get()).forEach((x) =>
|
|
794
|
-
api.log(x.toString())
|
|
797
|
+
api.log(x.toString()),
|
|
795
798
|
);
|
|
796
799
|
}
|
|
797
|
-
}
|
|
800
|
+
},
|
|
798
801
|
})
|
|
799
802
|
.strict()
|
|
800
803
|
.demandCommand();
|
|
@@ -812,18 +815,18 @@ export const cli = async (args?: string[]) => {
|
|
|
812
815
|
yargs.positional("peer-id", {
|
|
813
816
|
describe: "Peer id",
|
|
814
817
|
type: "string",
|
|
815
|
-
demandOption: true
|
|
818
|
+
demandOption: true,
|
|
816
819
|
});
|
|
817
820
|
return yargs;
|
|
818
821
|
},
|
|
819
822
|
handler: async (args) => {
|
|
820
823
|
const peerId: PeerId = peerIdFromString(
|
|
821
|
-
args["peer-id"]
|
|
824
|
+
args["peer-id"],
|
|
822
825
|
);
|
|
823
826
|
for (const api of apis) {
|
|
824
827
|
await api.api.access.allow(peerId);
|
|
825
828
|
}
|
|
826
|
-
}
|
|
829
|
+
},
|
|
827
830
|
})
|
|
828
831
|
.command({
|
|
829
832
|
command: "deny <peer-id>",
|
|
@@ -831,7 +834,7 @@ export const cli = async (args?: string[]) => {
|
|
|
831
834
|
builder: (yargs: yargs.Argv) => {
|
|
832
835
|
yargs.positional("peer-id", {
|
|
833
836
|
describe: "Peer id",
|
|
834
|
-
demandOption: true
|
|
837
|
+
demandOption: true,
|
|
835
838
|
});
|
|
836
839
|
return yargs;
|
|
837
840
|
},
|
|
@@ -840,11 +843,11 @@ export const cli = async (args?: string[]) => {
|
|
|
840
843
|
for (const api of apis) {
|
|
841
844
|
await api.api.access.deny(peerId);
|
|
842
845
|
}
|
|
843
|
-
}
|
|
846
|
+
},
|
|
844
847
|
})
|
|
845
848
|
.strict()
|
|
846
849
|
.demandCommand();
|
|
847
|
-
}
|
|
850
|
+
},
|
|
848
851
|
)
|
|
849
852
|
.command("network", "Manage network", (yargs) => {
|
|
850
853
|
yargs
|
|
@@ -855,7 +858,7 @@ export const cli = async (args?: string[]) => {
|
|
|
855
858
|
for (const api of apis) {
|
|
856
859
|
await api.api.network.bootstrap();
|
|
857
860
|
}
|
|
858
|
-
}
|
|
861
|
+
},
|
|
859
862
|
})
|
|
860
863
|
.strict()
|
|
861
864
|
.demandCommand();
|
|
@@ -875,7 +878,7 @@ export const cli = async (args?: string[]) => {
|
|
|
875
878
|
type: "boolean",
|
|
876
879
|
describe: "Replicate data on this topic",
|
|
877
880
|
aliases: "r",
|
|
878
|
-
default: false
|
|
881
|
+
default: false,
|
|
879
882
|
});
|
|
880
883
|
return yargs;
|
|
881
884
|
},
|
|
@@ -891,12 +894,12 @@ export const cli = async (args?: string[]) => {
|
|
|
891
894
|
console.log("Not subscribed to any topics");
|
|
892
895
|
} */
|
|
893
896
|
console.error("Not implemented");
|
|
894
|
-
}
|
|
897
|
+
},
|
|
895
898
|
})
|
|
896
899
|
.strict()
|
|
897
900
|
.demandCommand();
|
|
898
901
|
return yargs;
|
|
899
|
-
}
|
|
902
|
+
},
|
|
900
903
|
)
|
|
901
904
|
.command("program", "Manage programs", (yargs) => {
|
|
902
905
|
yargs
|
|
@@ -907,7 +910,7 @@ export const cli = async (args?: string[]) => {
|
|
|
907
910
|
yargs.positional("address", {
|
|
908
911
|
type: "string",
|
|
909
912
|
describe: "Program address",
|
|
910
|
-
demandOption: true
|
|
913
|
+
demandOption: true,
|
|
911
914
|
});
|
|
912
915
|
return yargs;
|
|
913
916
|
},
|
|
@@ -915,7 +918,7 @@ export const cli = async (args?: string[]) => {
|
|
|
915
918
|
handler: async (args) => {
|
|
916
919
|
for (const api of apis) {
|
|
917
920
|
const program = await api.api.program.has(
|
|
918
|
-
args.address
|
|
921
|
+
args.address,
|
|
919
922
|
);
|
|
920
923
|
if (!program) {
|
|
921
924
|
api.log(chalk.red("Closed"));
|
|
@@ -923,7 +926,7 @@ export const cli = async (args?: string[]) => {
|
|
|
923
926
|
api.log(chalk.green("Open"));
|
|
924
927
|
}
|
|
925
928
|
}
|
|
926
|
-
}
|
|
929
|
+
},
|
|
927
930
|
})
|
|
928
931
|
.command({
|
|
929
932
|
command: "drop <address>",
|
|
@@ -932,7 +935,7 @@ export const cli = async (args?: string[]) => {
|
|
|
932
935
|
yargs.positional("address", {
|
|
933
936
|
type: "string",
|
|
934
937
|
describe: "Program address",
|
|
935
|
-
demandOption: true
|
|
938
|
+
demandOption: true,
|
|
936
939
|
});
|
|
937
940
|
return yargs;
|
|
938
941
|
},
|
|
@@ -946,12 +949,12 @@ export const cli = async (args?: string[]) => {
|
|
|
946
949
|
chalk.red(
|
|
947
950
|
`Failed to drop ${
|
|
948
951
|
args.address
|
|
949
|
-
}: ${error.toString()}
|
|
950
|
-
)
|
|
952
|
+
}: ${error.toString()}`,
|
|
953
|
+
),
|
|
951
954
|
);
|
|
952
955
|
}
|
|
953
956
|
}
|
|
954
|
-
}
|
|
957
|
+
},
|
|
955
958
|
})
|
|
956
959
|
.command({
|
|
957
960
|
command: "close <address>",
|
|
@@ -960,7 +963,7 @@ export const cli = async (args?: string[]) => {
|
|
|
960
963
|
yargs.positional("address", {
|
|
961
964
|
type: "string",
|
|
962
965
|
describe: "Program address",
|
|
963
|
-
demandOption: true
|
|
966
|
+
demandOption: true,
|
|
964
967
|
});
|
|
965
968
|
return yargs;
|
|
966
969
|
},
|
|
@@ -969,7 +972,7 @@ export const cli = async (args?: string[]) => {
|
|
|
969
972
|
for (const api of apis) {
|
|
970
973
|
await api.api.program.close(args.address);
|
|
971
974
|
}
|
|
972
|
-
}
|
|
975
|
+
},
|
|
973
976
|
})
|
|
974
977
|
.command({
|
|
975
978
|
command: "list",
|
|
@@ -983,7 +986,7 @@ export const cli = async (args?: string[]) => {
|
|
|
983
986
|
api.log(chalk.green(p));
|
|
984
987
|
});
|
|
985
988
|
}
|
|
986
|
-
}
|
|
989
|
+
},
|
|
987
990
|
})
|
|
988
991
|
.command({
|
|
989
992
|
command: "variants",
|
|
@@ -997,7 +1000,7 @@ export const cli = async (args?: string[]) => {
|
|
|
997
1000
|
api.log(chalk.green(p));
|
|
998
1001
|
});
|
|
999
1002
|
}
|
|
1000
|
-
}
|
|
1003
|
+
},
|
|
1001
1004
|
})
|
|
1002
1005
|
.command({
|
|
1003
1006
|
command: "open [program]",
|
|
@@ -1006,34 +1009,34 @@ export const cli = async (args?: string[]) => {
|
|
|
1006
1009
|
yargs.positional("program", {
|
|
1007
1010
|
type: "string",
|
|
1008
1011
|
describe: "Identifier",
|
|
1009
|
-
demandOption: true
|
|
1012
|
+
demandOption: true,
|
|
1010
1013
|
});
|
|
1011
1014
|
yargs.option("base64", {
|
|
1012
1015
|
type: "string",
|
|
1013
1016
|
describe: "Base64 encoded serialized",
|
|
1014
|
-
aliases: "b"
|
|
1017
|
+
aliases: "b",
|
|
1015
1018
|
});
|
|
1016
1019
|
yargs.option("variant", {
|
|
1017
1020
|
type: "string",
|
|
1018
1021
|
describe: "Variant name",
|
|
1019
|
-
aliases: "v"
|
|
1022
|
+
aliases: "v",
|
|
1020
1023
|
});
|
|
1021
1024
|
return yargs;
|
|
1022
1025
|
},
|
|
1023
1026
|
handler: async (args) => {
|
|
1024
1027
|
if (!args.base64 && !args.variant) {
|
|
1025
1028
|
throw new Error(
|
|
1026
|
-
"Either base64 or variant argument needs to be provided"
|
|
1029
|
+
"Either base64 or variant argument needs to be provided",
|
|
1027
1030
|
);
|
|
1028
1031
|
}
|
|
1029
1032
|
let startArg: StartProgram;
|
|
1030
1033
|
if (args.base64) {
|
|
1031
1034
|
startArg = {
|
|
1032
|
-
base64: args.base64
|
|
1035
|
+
base64: args.base64,
|
|
1033
1036
|
};
|
|
1034
1037
|
} else {
|
|
1035
1038
|
startArg = {
|
|
1036
|
-
variant: args.variant
|
|
1039
|
+
variant: args.variant,
|
|
1037
1040
|
};
|
|
1038
1041
|
}
|
|
1039
1042
|
for (const api of apis) {
|
|
@@ -1042,7 +1045,7 @@ export const cli = async (args?: string[]) => {
|
|
|
1042
1045
|
api.log("Started program with address: ");
|
|
1043
1046
|
api.log(chalk.green(address.toString()));
|
|
1044
1047
|
}
|
|
1045
|
-
}
|
|
1048
|
+
},
|
|
1046
1049
|
})
|
|
1047
1050
|
.strict()
|
|
1048
1051
|
.demandCommand();
|
|
@@ -1056,7 +1059,7 @@ export const cli = async (args?: string[]) => {
|
|
|
1056
1059
|
type: "string",
|
|
1057
1060
|
describe:
|
|
1058
1061
|
"Installed dependency will be loaded with js import(...)",
|
|
1059
|
-
demandOption: true
|
|
1062
|
+
demandOption: true,
|
|
1060
1063
|
});
|
|
1061
1064
|
|
|
1062
1065
|
return yargs;
|
|
@@ -1076,7 +1079,7 @@ export const cli = async (args?: string[]) => {
|
|
|
1076
1079
|
installCommand = {
|
|
1077
1080
|
type: "tgz",
|
|
1078
1081
|
name: await getPackageName(packageName),
|
|
1079
|
-
base64
|
|
1082
|
+
base64,
|
|
1080
1083
|
};
|
|
1081
1084
|
} else {
|
|
1082
1085
|
installCommand = { type: "npm", name: packageName };
|
|
@@ -1086,13 +1089,13 @@ export const cli = async (args?: string[]) => {
|
|
|
1086
1089
|
const newPrograms =
|
|
1087
1090
|
await api.api.dependency.install(installCommand);
|
|
1088
1091
|
api.log(
|
|
1089
|
-
`New variants available (${newPrograms.length})
|
|
1092
|
+
`New variants available (${newPrograms.length}):`,
|
|
1090
1093
|
);
|
|
1091
1094
|
newPrograms.forEach((p) => {
|
|
1092
1095
|
api.log(chalk.green(p));
|
|
1093
1096
|
});
|
|
1094
1097
|
}
|
|
1095
|
-
}
|
|
1098
|
+
},
|
|
1096
1099
|
})
|
|
1097
1100
|
.command({
|
|
1098
1101
|
command: "restart",
|
|
@@ -1101,7 +1104,7 @@ export const cli = async (args?: string[]) => {
|
|
|
1101
1104
|
for (const api of apis) {
|
|
1102
1105
|
await api.api.restart();
|
|
1103
1106
|
}
|
|
1104
|
-
}
|
|
1107
|
+
},
|
|
1105
1108
|
})
|
|
1106
1109
|
.command({
|
|
1107
1110
|
command: "stop",
|
|
@@ -1110,7 +1113,7 @@ export const cli = async (args?: string[]) => {
|
|
|
1110
1113
|
for (const api of apis) {
|
|
1111
1114
|
await api.api.stop();
|
|
1112
1115
|
}
|
|
1113
|
-
}
|
|
1116
|
+
},
|
|
1114
1117
|
})
|
|
1115
1118
|
.help()
|
|
1116
1119
|
.strict()
|
|
@@ -1129,7 +1132,7 @@ export const cli = async (args?: string[]) => {
|
|
|
1129
1132
|
rl.prompt(true);
|
|
1130
1133
|
});
|
|
1131
1134
|
}
|
|
1132
|
-
}
|
|
1135
|
+
},
|
|
1133
1136
|
})
|
|
1134
1137
|
.help()
|
|
1135
1138
|
.strict()
|