@peerbit/server 5.0.33-efee9d3 → 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.d.ts.map +1 -0
- package/{lib/esm → dist/src}/aws.js +43 -45
- package/dist/src/aws.js.map +1 -0
- package/{lib/esm → dist/src}/bin.js.map +1 -1
- package/dist/src/cli.d.ts.map +1 -0
- package/{lib/esm → dist/src}/cli.js +106 -107
- package/dist/src/cli.js.map +1 -0
- package/{lib/esm → dist/src}/client.d.ts +3 -3
- package/dist/src/client.d.ts.map +1 -0
- package/{lib/esm → dist/src}/client.js +28 -28
- package/dist/src/client.js.map +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/{lib/esm → dist/src}/docker.js +1 -1
- package/{lib/esm → dist/src}/docker.js.map +1 -1
- package/{lib/esm → dist/src}/domain.d.ts +2 -9
- package/dist/src/domain.d.ts.map +1 -0
- package/{lib/esm → dist/src}/domain.js +6 -12
- package/dist/src/domain.js.map +1 -0
- package/{lib/esm → dist/src}/peerbit.d.ts +1 -1
- package/dist/src/peerbit.d.ts.map +1 -0
- package/{lib/esm → dist/src}/peerbit.js +10 -10
- package/dist/src/peerbit.js.map +1 -0
- package/{lib/esm → dist/src}/remotes.d.ts +2 -2
- package/{lib/esm → dist/src}/remotes.js +1 -1
- package/{lib/esm → dist/src}/server.d.ts +2 -3
- 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 +1 -2
- package/dist/src/session.d.ts.map +1 -0
- package/{lib/esm → dist/src}/session.js +2 -3
- package/dist/src/session.js.map +1 -0
- package/{lib/esm → dist/src}/signed-request.d.ts +2 -3
- package/dist/src/signed-request.d.ts.map +1 -0
- package/{lib/esm → dist/src}/signed-request.js +2 -3
- package/dist/src/signed-request.js.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 +33 -20
- package/src/aws.ts +57 -58
- package/src/bin.ts +1 -0
- package/src/cli.ts +158 -152
- package/src/client.ts +88 -88
- package/src/config.ts +9 -9
- package/src/docker.ts +2 -2
- package/src/domain.ts +15 -21
- package/src/peerbit.ts +14 -13
- package/src/remotes.ts +2 -2
- package/src/server.ts +62 -70
- package/src/session.ts +7 -7
- package/src/signed-request.ts +7 -7
- package/src/trust.ts +1 -1
- package/lib/esm/aws.d.ts.map +0 -1
- package/lib/esm/aws.js.map +0 -1
- package/lib/esm/cli.d.ts.map +0 -1
- package/lib/esm/cli.js.map +0 -1
- package/lib/esm/client.d.ts.map +0 -1
- package/lib/esm/client.js.map +0 -1
- package/lib/esm/config.d.ts.map +0 -1
- package/lib/esm/config.js.map +0 -1
- package/lib/esm/domain.d.ts.map +0 -1
- package/lib/esm/domain.js.map +0 -1
- package/lib/esm/peerbit.d.ts.map +0 -1
- package/lib/esm/peerbit.js.map +0 -1
- package/lib/esm/server.d.ts.map +0 -1
- package/lib/esm/server.js.map +0 -1
- package/lib/esm/session.d.ts.map +0 -1
- package/lib/esm/session.js.map +0 -1
- package/lib/esm/signed-request.d.ts.map +0 -1
- package/lib/esm/signed-request.js.map +0 -1
- package/lib/tsconfig.tsbuildinfo +0 -1
- package/lib/ui/assets/index-BC4oCu-g.js +0 -6
- package/lib/ui/assets/index-CvfEshgH.js +0 -79
- 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.d.ts +0 -0
- /package/{lib/esm → dist/src}/aws.browser.d.ts.map +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}/aws.d.ts +0 -0
- /package/{lib/esm → dist/src}/bin.d.ts +0 -0
- /package/{lib/esm → dist/src}/bin.d.ts.map +0 -0
- /package/{lib/esm → dist/src}/bin.js +0 -0
- /package/{lib/esm → dist/src}/cli.d.ts +0 -0
- /package/{lib/esm → dist/src}/config.browser.d.ts +0 -0
- /package/{lib/esm → dist/src}/config.browser.d.ts.map +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}/config.d.ts +0 -0
- /package/{lib/esm → dist/src}/docker.browser.d.ts +0 -0
- /package/{lib/esm → dist/src}/docker.browser.d.ts.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}/docker.d.ts +0 -0
- /package/{lib/esm → dist/src}/docker.d.ts.map +0 -0
- /package/{lib/esm → dist/src}/index.d.ts +0 -0
- /package/{lib/esm → dist/src}/index.d.ts.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.d.ts +0 -0
- /package/{lib/esm → dist/src}/remotes.browser.d.ts.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.d.ts.map +0 -0
- /package/{lib/esm → dist/src}/remotes.js.map +0 -0
- /package/{lib/esm → dist/src}/routes.d.ts +0 -0
- /package/{lib/esm → dist/src}/routes.d.ts.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.d.ts +0 -0
- /package/{lib/esm → dist/src}/server.browser.d.ts.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}/trust.browser.d.ts +0 -0
- /package/{lib/esm → dist/src}/trust.browser.d.ts.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.d.ts +0 -0
- /package/{lib/esm → dist/src}/trust.d.ts.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.d.ts +0 -0
- /package/{lib/esm → dist/src}/types.d.ts.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 fs from "fs";
|
|
27
|
-
import path from "path";
|
|
28
|
-
import { toBase64 } from "@peerbit/crypto";
|
|
27
|
+
import {
|
|
28
|
+
createTestDomain,
|
|
29
|
+
getDomainFromConfig,
|
|
30
|
+
loadConfig,
|
|
31
|
+
startCertbot,
|
|
32
|
+
} from "./domain.js";
|
|
29
33
|
import { DEFAULT_REMOTE_GROUP, type RemoteObject, Remotes } from "./remotes.js";
|
|
30
|
-
import { peerIdFromString } from "@libp2p/peer-id";
|
|
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({
|
|
@@ -299,23 +302,23 @@ export const cli = async (args?: string[]) => {
|
|
|
299
302
|
region: args.region,
|
|
300
303
|
credentials: args.accessKeyId
|
|
301
304
|
? {
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
: undefined
|
|
305
|
+
accessKeyId: args.accessKeyId,
|
|
306
|
+
secretAccessKey: args.secretAccessKey,
|
|
307
|
+
}
|
|
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,14 +374,14 @@ 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
|
},
|
|
@@ -387,29 +390,30 @@ export const cli = async (args?: string[]) => {
|
|
|
387
390
|
args.access?.length > 0
|
|
388
391
|
? args.access.map((x: any) => peerIdFromString(x))
|
|
389
392
|
: [
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
393
|
+
await (
|
|
394
|
+
await getKeypair(args.directory)
|
|
395
|
+
).publicKey.toPeerId(),
|
|
396
|
+
];
|
|
394
397
|
const nodes = await launchNodes({
|
|
395
398
|
email: "marcus@dao.xyz",
|
|
396
399
|
count: args.count,
|
|
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
|
-
`Waiting for ${args.count} ${
|
|
405
|
-
|
|
407
|
+
`Waiting for ${args.count} ${
|
|
408
|
+
args.count > 1 ? "nodes" : "node"
|
|
409
|
+
} to spawn. This might take a few minutes. You can watch the progress in your AWS console.`,
|
|
406
410
|
);
|
|
407
411
|
const twirlTimer = (function () {
|
|
408
412
|
const P = ["\\", "|", "/", "-"];
|
|
409
413
|
let x = 0;
|
|
410
414
|
return setInterval(function () {
|
|
411
415
|
process.stdout.write(
|
|
412
|
-
"\r" + "Loading: " + chalk.hex(colors[x])(P[x++])
|
|
416
|
+
"\r" + "Loading: " + chalk.hex(colors[x])(P[x++]),
|
|
413
417
|
);
|
|
414
418
|
x &= 3;
|
|
415
419
|
}, 250);
|
|
@@ -425,14 +429,15 @@ export const cli = async (args?: string[]) => {
|
|
|
425
429
|
origin: {
|
|
426
430
|
type: "aws",
|
|
427
431
|
instanceId: node.instanceId,
|
|
428
|
-
region: node.region
|
|
429
|
-
}
|
|
432
|
+
region: node.region,
|
|
433
|
+
},
|
|
430
434
|
});
|
|
431
435
|
} catch (error: any) {
|
|
432
436
|
process.stdout.write("\r");
|
|
433
437
|
console.error(
|
|
434
|
-
`Error waiting for domain for ip: ${
|
|
435
|
-
|
|
438
|
+
`Error waiting for domain for ip: ${
|
|
439
|
+
node.publicIp
|
|
440
|
+
} to be available: ${error?.toString()}`,
|
|
436
441
|
);
|
|
437
442
|
}
|
|
438
443
|
}
|
|
@@ -442,7 +447,7 @@ export const cli = async (args?: string[]) => {
|
|
|
442
447
|
for (const node of nodes) {
|
|
443
448
|
console.log(chalk.green(node.name));
|
|
444
449
|
}
|
|
445
|
-
}
|
|
450
|
+
},
|
|
446
451
|
})
|
|
447
452
|
.strict()
|
|
448
453
|
.demandCommand();
|
|
@@ -454,21 +459,21 @@ export const cli = async (args?: string[]) => {
|
|
|
454
459
|
killArgs.option("all", {
|
|
455
460
|
describe: "Kill all nodes",
|
|
456
461
|
type: "boolean",
|
|
457
|
-
default: false
|
|
462
|
+
default: false,
|
|
458
463
|
});
|
|
459
464
|
killArgs.positional("name", {
|
|
460
465
|
type: "string",
|
|
461
466
|
describe: "Remote name",
|
|
462
467
|
default: "localhost",
|
|
463
468
|
demandOption: false,
|
|
464
|
-
array: true
|
|
469
|
+
array: true,
|
|
465
470
|
});
|
|
466
471
|
killArgs.option("directory", {
|
|
467
472
|
describe: "Peerbit directory",
|
|
468
473
|
defaultDescription: "~.peerbit",
|
|
469
474
|
type: "string",
|
|
470
475
|
alias: "d",
|
|
471
|
-
default: getHomeConfigDir()
|
|
476
|
+
default: getHomeConfigDir(),
|
|
472
477
|
});
|
|
473
478
|
return killArgs;
|
|
474
479
|
},
|
|
@@ -480,12 +485,12 @@ export const cli = async (args?: string[]) => {
|
|
|
480
485
|
if (remote.origin?.type === "aws") {
|
|
481
486
|
await terminateNode({
|
|
482
487
|
instanceId: remote.origin.instanceId,
|
|
483
|
-
region: remote.origin.region
|
|
488
|
+
region: remote.origin.region,
|
|
484
489
|
});
|
|
485
490
|
}
|
|
486
491
|
}
|
|
487
492
|
}
|
|
488
|
-
}
|
|
493
|
+
},
|
|
489
494
|
})
|
|
490
495
|
.command({
|
|
491
496
|
command: "list",
|
|
@@ -497,7 +502,7 @@ export const cli = async (args?: string[]) => {
|
|
|
497
502
|
defaultDescription: "~.peerbit",
|
|
498
503
|
type: "string",
|
|
499
504
|
alias: "d",
|
|
500
|
-
default: getHomeConfigDir()
|
|
505
|
+
default: getHomeConfigDir(),
|
|
501
506
|
});
|
|
502
507
|
|
|
503
508
|
return yargs;
|
|
@@ -509,11 +514,11 @@ export const cli = async (args?: string[]) => {
|
|
|
509
514
|
const all = allRemotes;
|
|
510
515
|
const apis = await Promise.all(
|
|
511
516
|
all.map(async (remote) =>
|
|
512
|
-
createClient(await getKeypair(args.directory), remote)
|
|
513
|
-
)
|
|
517
|
+
createClient(await getKeypair(args.directory), remote),
|
|
518
|
+
),
|
|
514
519
|
);
|
|
515
520
|
const resolvedOrRejected = await Promise.allSettled(
|
|
516
|
-
apis.map((x) => x.peer.id.get())
|
|
521
|
+
apis.map((x) => x.peer.id.get()),
|
|
517
522
|
);
|
|
518
523
|
|
|
519
524
|
if (all.length > 0) {
|
|
@@ -528,7 +533,7 @@ export const cli = async (args?: string[]) => {
|
|
|
528
533
|
resolvedOrRejected[ix].status === "fulfilled"
|
|
529
534
|
? chalk.green("Y")
|
|
530
535
|
: chalk.red("N"),
|
|
531
|
-
remote.address
|
|
536
|
+
remote.address,
|
|
532
537
|
];
|
|
533
538
|
rows.push(row);
|
|
534
539
|
}
|
|
@@ -536,13 +541,13 @@ export const cli = async (args?: string[]) => {
|
|
|
536
541
|
["Name", "Group", "Origin", "Online", "Address"].map((x) => {
|
|
537
542
|
return { value: x, align: "left" };
|
|
538
543
|
}),
|
|
539
|
-
rows
|
|
544
|
+
rows,
|
|
540
545
|
);
|
|
541
546
|
console.log(table.render());
|
|
542
547
|
} else {
|
|
543
548
|
console.log("No remotes found!");
|
|
544
549
|
}
|
|
545
|
-
}
|
|
550
|
+
},
|
|
546
551
|
})
|
|
547
552
|
.command({
|
|
548
553
|
command: "add <name> <address>",
|
|
@@ -552,25 +557,25 @@ export const cli = async (args?: string[]) => {
|
|
|
552
557
|
.positional("name", {
|
|
553
558
|
type: "string",
|
|
554
559
|
describe: "Remote address",
|
|
555
|
-
demandOption: true
|
|
560
|
+
demandOption: true,
|
|
556
561
|
})
|
|
557
562
|
.positional("address", {
|
|
558
563
|
type: "string",
|
|
559
564
|
describe: "Remote name",
|
|
560
|
-
demandOption: true
|
|
565
|
+
demandOption: true,
|
|
561
566
|
})
|
|
562
567
|
.option("group", {
|
|
563
568
|
describe: "Group name",
|
|
564
569
|
type: "string",
|
|
565
570
|
alias: "g",
|
|
566
|
-
default: DEFAULT_REMOTE_GROUP
|
|
571
|
+
default: DEFAULT_REMOTE_GROUP,
|
|
567
572
|
})
|
|
568
573
|
.option("directory", {
|
|
569
574
|
describe: "Peerbit directory",
|
|
570
575
|
defaultDescription: "~.peerbit",
|
|
571
576
|
type: "string",
|
|
572
577
|
alias: "d",
|
|
573
|
-
default: getHomeConfigDir()
|
|
578
|
+
default: getHomeConfigDir(),
|
|
574
579
|
});
|
|
575
580
|
|
|
576
581
|
return yargs;
|
|
@@ -580,7 +585,7 @@ export const cli = async (args?: string[]) => {
|
|
|
580
585
|
throw new Error("Remote can not be named 'localhost'");
|
|
581
586
|
}
|
|
582
587
|
const api = await createClient(await getKeypair(args.directory), {
|
|
583
|
-
address: args.address
|
|
588
|
+
address: args.address,
|
|
584
589
|
});
|
|
585
590
|
try {
|
|
586
591
|
await api.program.list();
|
|
@@ -594,9 +599,9 @@ export const cli = async (args?: string[]) => {
|
|
|
594
599
|
remotes.add({
|
|
595
600
|
name: args.name,
|
|
596
601
|
address: args.address,
|
|
597
|
-
group: args.group
|
|
602
|
+
group: args.group,
|
|
598
603
|
});
|
|
599
|
-
}
|
|
604
|
+
},
|
|
600
605
|
})
|
|
601
606
|
.command({
|
|
602
607
|
command: "remove <name>",
|
|
@@ -607,14 +612,14 @@ export const cli = async (args?: string[]) => {
|
|
|
607
612
|
.positional("name", {
|
|
608
613
|
type: "string",
|
|
609
614
|
describe: "Remote address",
|
|
610
|
-
demandOption: true
|
|
615
|
+
demandOption: true,
|
|
611
616
|
})
|
|
612
617
|
.option("directory", {
|
|
613
618
|
describe: "Peerbit directory",
|
|
614
619
|
defaultDescription: "~.peerbit",
|
|
615
620
|
type: "string",
|
|
616
621
|
alias: "d",
|
|
617
|
-
default: getHomeConfigDir()
|
|
622
|
+
default: getHomeConfigDir(),
|
|
618
623
|
});
|
|
619
624
|
|
|
620
625
|
return yargs;
|
|
@@ -623,15 +628,15 @@ export const cli = async (args?: string[]) => {
|
|
|
623
628
|
const remotes = new Remotes(getRemotesPath(args.directory));
|
|
624
629
|
if (remotes.remove(args.name)) {
|
|
625
630
|
console.log(
|
|
626
|
-
chalk.green("Removed remote with name: " + args.name)
|
|
631
|
+
chalk.green("Removed remote with name: " + args.name),
|
|
627
632
|
);
|
|
628
633
|
remotes.save();
|
|
629
634
|
} else {
|
|
630
635
|
console.log(
|
|
631
|
-
chalk.red("Did not find any remote with name: " + args.name)
|
|
636
|
+
chalk.red("Did not find any remote with name: " + args.name),
|
|
632
637
|
);
|
|
633
638
|
}
|
|
634
|
-
}
|
|
639
|
+
},
|
|
635
640
|
})
|
|
636
641
|
.command({
|
|
637
642
|
command: "connect [name...]",
|
|
@@ -643,26 +648,26 @@ export const cli = async (args?: string[]) => {
|
|
|
643
648
|
describe: "Remote name",
|
|
644
649
|
default: "localhost",
|
|
645
650
|
demandOption: false,
|
|
646
|
-
array: true
|
|
651
|
+
array: true,
|
|
647
652
|
})
|
|
648
653
|
.option("all", {
|
|
649
654
|
type: "boolean",
|
|
650
655
|
describe: "Connect to all nodes",
|
|
651
|
-
default: false
|
|
656
|
+
default: false,
|
|
652
657
|
})
|
|
653
658
|
.option("group", {
|
|
654
659
|
type: "string",
|
|
655
660
|
describe: "Remote group name",
|
|
656
661
|
alias: "g",
|
|
657
662
|
default: [],
|
|
658
|
-
array: true
|
|
663
|
+
array: true,
|
|
659
664
|
})
|
|
660
665
|
.option("directory", {
|
|
661
666
|
describe: "Peerbit directory",
|
|
662
667
|
defaultDescription: "~.peerbit",
|
|
663
668
|
type: "string",
|
|
664
669
|
alias: "d",
|
|
665
|
-
default: getHomeConfigDir()
|
|
670
|
+
default: getHomeConfigDir(),
|
|
666
671
|
});
|
|
667
672
|
return yargs;
|
|
668
673
|
},
|
|
@@ -693,7 +698,7 @@ export const cli = async (args?: string[]) => {
|
|
|
693
698
|
selectedRemotes.push({
|
|
694
699
|
address: "http://localhost:" + LOCAL_API_PORT,
|
|
695
700
|
name: "localhost",
|
|
696
|
-
group: DEFAULT_REMOTE_GROUP
|
|
701
|
+
group: DEFAULT_REMOTE_GROUP,
|
|
697
702
|
});
|
|
698
703
|
} else {
|
|
699
704
|
const remote = remotes.getByName(name);
|
|
@@ -722,7 +727,7 @@ export const cli = async (args?: string[]) => {
|
|
|
722
727
|
|
|
723
728
|
if (selectedRemotes.length === 0) {
|
|
724
729
|
console.log(
|
|
725
|
-
chalk.red("No remotes matched your connection condition")
|
|
730
|
+
chalk.red("No remotes matched your connection condition"),
|
|
726
731
|
);
|
|
727
732
|
} else {
|
|
728
733
|
console.log(`Connected to (${selectedRemotes.length}):`);
|
|
@@ -736,16 +741,16 @@ export const cli = async (args?: string[]) => {
|
|
|
736
741
|
chalkBg(remote.name),
|
|
737
742
|
maxNameLength,
|
|
738
743
|
" ",
|
|
739
|
-
remote.name.length
|
|
744
|
+
remote.name.length,
|
|
740
745
|
) +
|
|
741
|
-
|
|
742
|
-
|
|
746
|
+
": " +
|
|
747
|
+
string,
|
|
743
748
|
);
|
|
744
749
|
|
|
745
750
|
apis.push({
|
|
746
751
|
log: logFn,
|
|
747
752
|
name: remote.name,
|
|
748
|
-
api: await createClient(keypair, remote)
|
|
753
|
+
api: await createClient(keypair, remote),
|
|
749
754
|
});
|
|
750
755
|
}
|
|
751
756
|
|
|
@@ -755,7 +760,7 @@ export const cli = async (args?: string[]) => {
|
|
|
755
760
|
await api.api.program.list();
|
|
756
761
|
} catch (error) {
|
|
757
762
|
throw new Error(
|
|
758
|
-
`Failed to connect to '${api.name}': ${error?.toString()}
|
|
763
|
+
`Failed to connect to '${api.name}': ${error?.toString()}`,
|
|
759
764
|
);
|
|
760
765
|
}
|
|
761
766
|
}
|
|
@@ -764,7 +769,7 @@ export const cli = async (args?: string[]) => {
|
|
|
764
769
|
input: process.stdin,
|
|
765
770
|
output: process.stdout,
|
|
766
771
|
terminal: true,
|
|
767
|
-
historySize: 100
|
|
772
|
+
historySize: 100,
|
|
768
773
|
});
|
|
769
774
|
|
|
770
775
|
console.log("Write 'help' to show commands.\n");
|
|
@@ -781,7 +786,7 @@ export const cli = async (args?: string[]) => {
|
|
|
781
786
|
for (const api of apis) {
|
|
782
787
|
api.log((await api.api.peer.id.get()).toString());
|
|
783
788
|
}
|
|
784
|
-
}
|
|
789
|
+
},
|
|
785
790
|
})
|
|
786
791
|
.command({
|
|
787
792
|
command: "address",
|
|
@@ -789,10 +794,10 @@ export const cli = async (args?: string[]) => {
|
|
|
789
794
|
handler: async (args) => {
|
|
790
795
|
for (const api of apis) {
|
|
791
796
|
(await api.api.peer.addresses.get()).forEach((x) =>
|
|
792
|
-
api.log(x.toString())
|
|
797
|
+
api.log(x.toString()),
|
|
793
798
|
);
|
|
794
799
|
}
|
|
795
|
-
}
|
|
800
|
+
},
|
|
796
801
|
})
|
|
797
802
|
.strict()
|
|
798
803
|
.demandCommand();
|
|
@@ -810,18 +815,18 @@ export const cli = async (args?: string[]) => {
|
|
|
810
815
|
yargs.positional("peer-id", {
|
|
811
816
|
describe: "Peer id",
|
|
812
817
|
type: "string",
|
|
813
|
-
demandOption: true
|
|
818
|
+
demandOption: true,
|
|
814
819
|
});
|
|
815
820
|
return yargs;
|
|
816
821
|
},
|
|
817
822
|
handler: async (args) => {
|
|
818
823
|
const peerId: PeerId = peerIdFromString(
|
|
819
|
-
args["peer-id"]
|
|
824
|
+
args["peer-id"],
|
|
820
825
|
);
|
|
821
826
|
for (const api of apis) {
|
|
822
827
|
await api.api.access.allow(peerId);
|
|
823
828
|
}
|
|
824
|
-
}
|
|
829
|
+
},
|
|
825
830
|
})
|
|
826
831
|
.command({
|
|
827
832
|
command: "deny <peer-id>",
|
|
@@ -829,7 +834,7 @@ export const cli = async (args?: string[]) => {
|
|
|
829
834
|
builder: (yargs: yargs.Argv) => {
|
|
830
835
|
yargs.positional("peer-id", {
|
|
831
836
|
describe: "Peer id",
|
|
832
|
-
demandOption: true
|
|
837
|
+
demandOption: true,
|
|
833
838
|
});
|
|
834
839
|
return yargs;
|
|
835
840
|
},
|
|
@@ -838,11 +843,11 @@ export const cli = async (args?: string[]) => {
|
|
|
838
843
|
for (const api of apis) {
|
|
839
844
|
await api.api.access.deny(peerId);
|
|
840
845
|
}
|
|
841
|
-
}
|
|
846
|
+
},
|
|
842
847
|
})
|
|
843
848
|
.strict()
|
|
844
849
|
.demandCommand();
|
|
845
|
-
}
|
|
850
|
+
},
|
|
846
851
|
)
|
|
847
852
|
.command("network", "Manage network", (yargs) => {
|
|
848
853
|
yargs
|
|
@@ -853,7 +858,7 @@ export const cli = async (args?: string[]) => {
|
|
|
853
858
|
for (const api of apis) {
|
|
854
859
|
await api.api.network.bootstrap();
|
|
855
860
|
}
|
|
856
|
-
}
|
|
861
|
+
},
|
|
857
862
|
})
|
|
858
863
|
.strict()
|
|
859
864
|
.demandCommand();
|
|
@@ -873,7 +878,7 @@ export const cli = async (args?: string[]) => {
|
|
|
873
878
|
type: "boolean",
|
|
874
879
|
describe: "Replicate data on this topic",
|
|
875
880
|
aliases: "r",
|
|
876
|
-
default: false
|
|
881
|
+
default: false,
|
|
877
882
|
});
|
|
878
883
|
return yargs;
|
|
879
884
|
},
|
|
@@ -889,12 +894,12 @@ export const cli = async (args?: string[]) => {
|
|
|
889
894
|
console.log("Not subscribed to any topics");
|
|
890
895
|
} */
|
|
891
896
|
console.error("Not implemented");
|
|
892
|
-
}
|
|
897
|
+
},
|
|
893
898
|
})
|
|
894
899
|
.strict()
|
|
895
900
|
.demandCommand();
|
|
896
901
|
return yargs;
|
|
897
|
-
}
|
|
902
|
+
},
|
|
898
903
|
)
|
|
899
904
|
.command("program", "Manage programs", (yargs) => {
|
|
900
905
|
yargs
|
|
@@ -905,7 +910,7 @@ export const cli = async (args?: string[]) => {
|
|
|
905
910
|
yargs.positional("address", {
|
|
906
911
|
type: "string",
|
|
907
912
|
describe: "Program address",
|
|
908
|
-
demandOption: true
|
|
913
|
+
demandOption: true,
|
|
909
914
|
});
|
|
910
915
|
return yargs;
|
|
911
916
|
},
|
|
@@ -913,7 +918,7 @@ export const cli = async (args?: string[]) => {
|
|
|
913
918
|
handler: async (args) => {
|
|
914
919
|
for (const api of apis) {
|
|
915
920
|
const program = await api.api.program.has(
|
|
916
|
-
args.address
|
|
921
|
+
args.address,
|
|
917
922
|
);
|
|
918
923
|
if (!program) {
|
|
919
924
|
api.log(chalk.red("Closed"));
|
|
@@ -921,7 +926,7 @@ export const cli = async (args?: string[]) => {
|
|
|
921
926
|
api.log(chalk.green("Open"));
|
|
922
927
|
}
|
|
923
928
|
}
|
|
924
|
-
}
|
|
929
|
+
},
|
|
925
930
|
})
|
|
926
931
|
.command({
|
|
927
932
|
command: "drop <address>",
|
|
@@ -930,7 +935,7 @@ export const cli = async (args?: string[]) => {
|
|
|
930
935
|
yargs.positional("address", {
|
|
931
936
|
type: "string",
|
|
932
937
|
describe: "Program address",
|
|
933
|
-
demandOption: true
|
|
938
|
+
demandOption: true,
|
|
934
939
|
});
|
|
935
940
|
return yargs;
|
|
936
941
|
},
|
|
@@ -942,13 +947,14 @@ export const cli = async (args?: string[]) => {
|
|
|
942
947
|
} catch (error: any) {
|
|
943
948
|
api.log(
|
|
944
949
|
chalk.red(
|
|
945
|
-
`Failed to drop ${
|
|
946
|
-
|
|
947
|
-
|
|
950
|
+
`Failed to drop ${
|
|
951
|
+
args.address
|
|
952
|
+
}: ${error.toString()}`,
|
|
953
|
+
),
|
|
948
954
|
);
|
|
949
955
|
}
|
|
950
956
|
}
|
|
951
|
-
}
|
|
957
|
+
},
|
|
952
958
|
})
|
|
953
959
|
.command({
|
|
954
960
|
command: "close <address>",
|
|
@@ -957,7 +963,7 @@ export const cli = async (args?: string[]) => {
|
|
|
957
963
|
yargs.positional("address", {
|
|
958
964
|
type: "string",
|
|
959
965
|
describe: "Program address",
|
|
960
|
-
demandOption: true
|
|
966
|
+
demandOption: true,
|
|
961
967
|
});
|
|
962
968
|
return yargs;
|
|
963
969
|
},
|
|
@@ -966,7 +972,7 @@ export const cli = async (args?: string[]) => {
|
|
|
966
972
|
for (const api of apis) {
|
|
967
973
|
await api.api.program.close(args.address);
|
|
968
974
|
}
|
|
969
|
-
}
|
|
975
|
+
},
|
|
970
976
|
})
|
|
971
977
|
.command({
|
|
972
978
|
command: "list",
|
|
@@ -980,7 +986,7 @@ export const cli = async (args?: string[]) => {
|
|
|
980
986
|
api.log(chalk.green(p));
|
|
981
987
|
});
|
|
982
988
|
}
|
|
983
|
-
}
|
|
989
|
+
},
|
|
984
990
|
})
|
|
985
991
|
.command({
|
|
986
992
|
command: "variants",
|
|
@@ -994,7 +1000,7 @@ export const cli = async (args?: string[]) => {
|
|
|
994
1000
|
api.log(chalk.green(p));
|
|
995
1001
|
});
|
|
996
1002
|
}
|
|
997
|
-
}
|
|
1003
|
+
},
|
|
998
1004
|
})
|
|
999
1005
|
.command({
|
|
1000
1006
|
command: "open [program]",
|
|
@@ -1003,34 +1009,34 @@ export const cli = async (args?: string[]) => {
|
|
|
1003
1009
|
yargs.positional("program", {
|
|
1004
1010
|
type: "string",
|
|
1005
1011
|
describe: "Identifier",
|
|
1006
|
-
demandOption: true
|
|
1012
|
+
demandOption: true,
|
|
1007
1013
|
});
|
|
1008
1014
|
yargs.option("base64", {
|
|
1009
1015
|
type: "string",
|
|
1010
1016
|
describe: "Base64 encoded serialized",
|
|
1011
|
-
aliases: "b"
|
|
1017
|
+
aliases: "b",
|
|
1012
1018
|
});
|
|
1013
1019
|
yargs.option("variant", {
|
|
1014
1020
|
type: "string",
|
|
1015
1021
|
describe: "Variant name",
|
|
1016
|
-
aliases: "v"
|
|
1022
|
+
aliases: "v",
|
|
1017
1023
|
});
|
|
1018
1024
|
return yargs;
|
|
1019
1025
|
},
|
|
1020
1026
|
handler: async (args) => {
|
|
1021
1027
|
if (!args.base64 && !args.variant) {
|
|
1022
1028
|
throw new Error(
|
|
1023
|
-
"Either base64 or variant argument needs to be provided"
|
|
1029
|
+
"Either base64 or variant argument needs to be provided",
|
|
1024
1030
|
);
|
|
1025
1031
|
}
|
|
1026
1032
|
let startArg: StartProgram;
|
|
1027
1033
|
if (args.base64) {
|
|
1028
1034
|
startArg = {
|
|
1029
|
-
base64: args.base64
|
|
1035
|
+
base64: args.base64,
|
|
1030
1036
|
};
|
|
1031
1037
|
} else {
|
|
1032
1038
|
startArg = {
|
|
1033
|
-
variant: args.variant
|
|
1039
|
+
variant: args.variant,
|
|
1034
1040
|
};
|
|
1035
1041
|
}
|
|
1036
1042
|
for (const api of apis) {
|
|
@@ -1039,7 +1045,7 @@ export const cli = async (args?: string[]) => {
|
|
|
1039
1045
|
api.log("Started program with address: ");
|
|
1040
1046
|
api.log(chalk.green(address.toString()));
|
|
1041
1047
|
}
|
|
1042
|
-
}
|
|
1048
|
+
},
|
|
1043
1049
|
})
|
|
1044
1050
|
.strict()
|
|
1045
1051
|
.demandCommand();
|
|
@@ -1053,7 +1059,7 @@ export const cli = async (args?: string[]) => {
|
|
|
1053
1059
|
type: "string",
|
|
1054
1060
|
describe:
|
|
1055
1061
|
"Installed dependency will be loaded with js import(...)",
|
|
1056
|
-
demandOption: true
|
|
1062
|
+
demandOption: true,
|
|
1057
1063
|
});
|
|
1058
1064
|
|
|
1059
1065
|
return yargs;
|
|
@@ -1073,7 +1079,7 @@ export const cli = async (args?: string[]) => {
|
|
|
1073
1079
|
installCommand = {
|
|
1074
1080
|
type: "tgz",
|
|
1075
1081
|
name: await getPackageName(packageName),
|
|
1076
|
-
base64
|
|
1082
|
+
base64,
|
|
1077
1083
|
};
|
|
1078
1084
|
} else {
|
|
1079
1085
|
installCommand = { type: "npm", name: packageName };
|
|
@@ -1083,13 +1089,13 @@ export const cli = async (args?: string[]) => {
|
|
|
1083
1089
|
const newPrograms =
|
|
1084
1090
|
await api.api.dependency.install(installCommand);
|
|
1085
1091
|
api.log(
|
|
1086
|
-
`New variants available (${newPrograms.length})
|
|
1092
|
+
`New variants available (${newPrograms.length}):`,
|
|
1087
1093
|
);
|
|
1088
1094
|
newPrograms.forEach((p) => {
|
|
1089
1095
|
api.log(chalk.green(p));
|
|
1090
1096
|
});
|
|
1091
1097
|
}
|
|
1092
|
-
}
|
|
1098
|
+
},
|
|
1093
1099
|
})
|
|
1094
1100
|
.command({
|
|
1095
1101
|
command: "restart",
|
|
@@ -1098,7 +1104,7 @@ export const cli = async (args?: string[]) => {
|
|
|
1098
1104
|
for (const api of apis) {
|
|
1099
1105
|
await api.api.restart();
|
|
1100
1106
|
}
|
|
1101
|
-
}
|
|
1107
|
+
},
|
|
1102
1108
|
})
|
|
1103
1109
|
.command({
|
|
1104
1110
|
command: "stop",
|
|
@@ -1107,7 +1113,7 @@ export const cli = async (args?: string[]) => {
|
|
|
1107
1113
|
for (const api of apis) {
|
|
1108
1114
|
await api.api.stop();
|
|
1109
1115
|
}
|
|
1110
|
-
}
|
|
1116
|
+
},
|
|
1111
1117
|
})
|
|
1112
1118
|
.help()
|
|
1113
1119
|
.strict()
|
|
@@ -1126,7 +1132,7 @@ export const cli = async (args?: string[]) => {
|
|
|
1126
1132
|
rl.prompt(true);
|
|
1127
1133
|
});
|
|
1128
1134
|
}
|
|
1129
|
-
}
|
|
1135
|
+
},
|
|
1130
1136
|
})
|
|
1131
1137
|
.help()
|
|
1132
1138
|
.strict()
|