@peerbit/server 5.6.0-1c918e0 → 5.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/aws.d.ts.map +1 -1
- package/dist/src/aws.js +26 -40
- package/dist/src/aws.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/ui/assets/{index-BeFPnrza.js → index-Dcbn6kSA.js} +3 -3
- package/dist/ui/index.html +1 -1
- package/package.json +89 -89
- package/src/aws.ts +31 -49
package/dist/ui/index.html
CHANGED
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
Learn how to configure a non-root public URL by running `npm run build`.
|
|
24
24
|
-->
|
|
25
25
|
<title>Peerbit</title>
|
|
26
|
-
<script type="module" crossorigin src="/assets/index-
|
|
26
|
+
<script type="module" crossorigin src="/assets/index-Dcbn6kSA.js"></script>
|
|
27
27
|
<link rel="stylesheet" crossorigin href="/assets/index-CIfVvUo9.css">
|
|
28
28
|
</head>
|
|
29
29
|
|
package/package.json
CHANGED
|
@@ -1,91 +1,91 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
2
|
+
"name": "@peerbit/server",
|
|
3
|
+
"version": "5.6.0",
|
|
4
|
+
"author": "dao.xyz",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/dao-xyz/peerbit"
|
|
8
|
+
},
|
|
9
|
+
"license": "Apache-2.0",
|
|
10
|
+
"type": "module",
|
|
11
|
+
"sideEffects": false,
|
|
12
|
+
"bin": {
|
|
13
|
+
"peerbit": "./dist/src/bin.js"
|
|
14
|
+
},
|
|
15
|
+
"module": "dist/src/index.js",
|
|
16
|
+
"types": "dist/src/index.d.ts",
|
|
17
|
+
"exports": {
|
|
18
|
+
"import": "./dist/src/index.js"
|
|
19
|
+
},
|
|
20
|
+
"browser": {
|
|
21
|
+
"./dist/src/server.js": "./dist/src/server.browser.js",
|
|
22
|
+
"./server.js": "./dist/src/server.browser.js",
|
|
23
|
+
"./dist/src/config.js": "./dist/src/config.browser.js",
|
|
24
|
+
"./config.js": "./dist/src/config.browser.js",
|
|
25
|
+
"./dist/src/remotes.js": "./dist/src/remotes.browser.js",
|
|
26
|
+
"./remotes.js": "./dist/src/remotes.browser.js",
|
|
27
|
+
"./dist/src/docker.js": "./dist/src/docker.browser.js",
|
|
28
|
+
"./docker.js": "./dist/src/docker.browser.js",
|
|
29
|
+
"./dist/src/aws.js": "./dist/src/aws.browser.js"
|
|
30
|
+
},
|
|
31
|
+
"files": [
|
|
32
|
+
"dist",
|
|
33
|
+
"src",
|
|
34
|
+
"src/nginx-template.conf",
|
|
35
|
+
"!src/test",
|
|
36
|
+
"!src/**/__tests__",
|
|
37
|
+
"!lib/**/__tests__",
|
|
38
|
+
"patches",
|
|
39
|
+
"LICENSE"
|
|
40
|
+
],
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
44
|
+
"engines": {
|
|
45
|
+
"node": ">=18"
|
|
46
|
+
},
|
|
47
|
+
"eslintConfig": {
|
|
48
|
+
"extends": "peerbit",
|
|
49
|
+
"parserOptions": {
|
|
50
|
+
"project": true,
|
|
51
|
+
"sourceType": "module"
|
|
52
|
+
},
|
|
53
|
+
"ignorePatterns": [
|
|
54
|
+
"!.aegir.js",
|
|
55
|
+
"test/ts-use",
|
|
56
|
+
"*.d.ts"
|
|
57
|
+
]
|
|
58
|
+
},
|
|
59
|
+
"scripts": {
|
|
60
|
+
"clean": "shx rm -rf lib/*",
|
|
61
|
+
"build": "yarn clean && yarn build-lib && yarn build-ui",
|
|
62
|
+
"build-lib": "tsc -p tsconfig.json",
|
|
63
|
+
"build-ui": "cd ../frontend && yarn build && cd ../node",
|
|
64
|
+
"postbuild": "cp src/nginx-template.conf dist/src/ && cp -r ../frontend/dist/. dist/ui",
|
|
65
|
+
"test": "aegir test --t node",
|
|
66
|
+
"lint": "aegir lint"
|
|
67
|
+
},
|
|
68
|
+
"devDependencies": {
|
|
69
|
+
"@peerbit/test-lib": "^0.0.1",
|
|
70
|
+
"@peerbit/test-utils": "2.1.57",
|
|
71
|
+
"@types/yargs": "17.0.24",
|
|
72
|
+
"aws-sdk": "^2.1259.0",
|
|
73
|
+
"dotenv": "^16.1.4",
|
|
74
|
+
"@types/tmp": "^0.2.3",
|
|
75
|
+
"@types/tar-stream": "^3.1.3",
|
|
76
|
+
"shx": "^0.3.4"
|
|
77
|
+
},
|
|
78
|
+
"dependencies": {
|
|
79
|
+
"axios": "^1.4.0",
|
|
80
|
+
"chalk": "^5.3.0",
|
|
81
|
+
"peerbit": "4.1.46",
|
|
82
|
+
"yargs": "^17.7.2",
|
|
83
|
+
"tar-stream": "^3.1.7",
|
|
84
|
+
"tmp": "^0.2.1",
|
|
85
|
+
"tty-table": "^4.2.1"
|
|
86
|
+
},
|
|
87
|
+
"optionalDependencies": {
|
|
88
|
+
"@aws-sdk/client-ec2": "^3.390.0",
|
|
89
|
+
"@aws-sdk/client-route-53": "^3.391.0"
|
|
90
|
+
}
|
|
91
91
|
}
|
package/src/aws.ts
CHANGED
|
@@ -249,58 +249,40 @@ export const launchNodes = async (properties: {
|
|
|
249
249
|
);
|
|
250
250
|
}
|
|
251
251
|
|
|
252
|
-
// wait for
|
|
253
|
-
const
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
const allPresent = foundInstances.length >= instanceIds.length;
|
|
270
|
-
const ips = new Map(
|
|
271
|
-
foundInstances
|
|
272
|
-
.filter((i) => i.InstanceId && i.PublicIpAddress)
|
|
273
|
-
.map((i) => [i.InstanceId!, i.PublicIpAddress!]),
|
|
274
|
-
);
|
|
275
|
-
const allHaveIp = instanceIds.every((id) => ips.has(id));
|
|
276
|
-
if (allPresent && allHaveIp) {
|
|
277
|
-
// reorder to original order
|
|
278
|
-
var publicIps = instanceIds.map((id) => ips.get(id)!);
|
|
279
|
-
if (publicIps.length > 0) {
|
|
280
|
-
// success
|
|
281
|
-
return publicIps.map((v, ix) => {
|
|
282
|
-
return {
|
|
283
|
-
instanceId: instanceOut.Instances![ix].InstanceId!,
|
|
284
|
-
publicIp: v,
|
|
285
|
-
name: names[ix],
|
|
286
|
-
region: regionString,
|
|
287
|
-
};
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
} catch (e: any) {
|
|
292
|
-
// AWS eventual consistency: sometimes returns InvalidInstanceID.NotFound immediately after RunInstances
|
|
293
|
-
const code = e?.Code || e?.name || e?.code;
|
|
294
|
-
if (code !== "InvalidInstanceID.NotFound") {
|
|
295
|
-
throw e;
|
|
296
|
-
}
|
|
252
|
+
// wait for instance ips to become available
|
|
253
|
+
const info = await client.send(
|
|
254
|
+
new DescribeInstancesCommand({
|
|
255
|
+
InstanceIds: instanceOut.Instances.map((x) => x.InstanceId!),
|
|
256
|
+
}),
|
|
257
|
+
);
|
|
258
|
+
const foundInstances = info
|
|
259
|
+
.Reservations!.map((x) => x.Instances!.map((y) => y))
|
|
260
|
+
.flat()!;
|
|
261
|
+
const foundIps: string[] = [];
|
|
262
|
+
for (const out of instanceOut.Instances) {
|
|
263
|
+
const foundInstance = foundInstances.find(
|
|
264
|
+
(x) => x!.InstanceId === out.InstanceId!,
|
|
265
|
+
);
|
|
266
|
+
if (!foundInstance!.PublicIpAddress) {
|
|
267
|
+
await delay(3000);
|
|
268
|
+
continue;
|
|
297
269
|
}
|
|
298
|
-
|
|
270
|
+
foundIps.push(foundInstance!.PublicIpAddress!);
|
|
299
271
|
}
|
|
272
|
+
let publicIps: string[] = foundIps;
|
|
300
273
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
274
|
+
if (publicIps.length === 0) {
|
|
275
|
+
throw new Error("Failed to resolve IPs for created instances");
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
return publicIps.map((v, ix) => {
|
|
279
|
+
return {
|
|
280
|
+
instanceId: instanceOut.Instances![ix].InstanceId!,
|
|
281
|
+
publicIp: v,
|
|
282
|
+
name: names[ix],
|
|
283
|
+
region: regionString,
|
|
284
|
+
};
|
|
285
|
+
}); // TODO types
|
|
304
286
|
};
|
|
305
287
|
|
|
306
288
|
export const terminateNode = async (properties: {
|