@peerbit/server 5.4.0-a762412 → 5.4.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/package.json CHANGED
@@ -1,91 +1,91 @@
1
1
  {
2
- "name": "@peerbit/server",
3
- "version": "5.4.0-a762412",
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-a762412",
70
- "@peerbit/test-utils": "2.1.45-a762412",
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.35-a762412",
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
- }
2
+ "name": "@peerbit/server",
3
+ "version": "5.4.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.45",
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.35",
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/server.ts CHANGED
@@ -9,7 +9,8 @@ import {
9
9
  getProgramFromVariants,
10
10
  } from "@peerbit/program";
11
11
  import { waitFor } from "@peerbit/time";
12
- import { execSync, spawn, spawnSync } from "child_process";
12
+ import { execSync, spawn } from "child_process";
13
+ import { spawnSync } from "child_process";
13
14
  import { setMaxListeners } from "events";
14
15
  import fs from "fs";
15
16
  import http from "http";
@@ -51,6 +52,9 @@ import type {
51
52
 
52
53
  const MAX_LISTENER_LIMIT = 1e5;
53
54
 
55
+ // eslint-disable-next-line @typescript-eslint/naming-convention
56
+ const __dirname = dirname(fileURLToPath(import.meta.url));
57
+
54
58
  const getInstallDir = (): string | null => {
55
59
  return (
56
60
  process.env.PEERBIT_MODULES_PATH ||
@@ -58,24 +62,6 @@ const getInstallDir = (): string | null => {
58
62
  null
59
63
  );
60
64
  };
61
-
62
- // eslint-disable-next-line @typescript-eslint/naming-convention
63
- const __dirname = dirname(fileURLToPath(import.meta.url));
64
-
65
- const extraNodePath = () => {
66
- const installDir = getInstallDir();
67
- return installDir ? path.join(installDir, "node_modules") : undefined;
68
- };
69
- const extra = extraNodePath();
70
- if (extra) {
71
- process.env.NODE_PATH = process.env.NODE_PATH
72
- ? process.env.NODE_PATH + path.delimiter + extra
73
- : extra;
74
-
75
- // always re-parse NODE_PATH for *this* process
76
- ((await import("module")).default as any)["_initPaths"]();
77
- }
78
-
79
65
  // add next to execSync
80
66
 
81
67
  const listVersions = (dir: string): Record<string, string> => {
@@ -274,36 +260,24 @@ export const startApiServer = async (
274
260
  const port = properties?.port ?? LOCAL_API_PORT;
275
261
 
276
262
  const restart = async () => {
277
- console.log(
278
- "Process will be lost during restart. Please find it using a process monitor. Or find it from the port e.g. 'lsof -i tcp:8001'",
263
+ await client.stop();
264
+ await stopAndWait(server);
265
+
266
+ // We filter out the reset command, since restarting means that we want to resume something
267
+ spawn(
268
+ process.argv.shift()!,
269
+ [
270
+ ...process.execArgv,
271
+ ...process.argv.filter((x) => x !== "--reset" && x !== "-r"),
272
+ ],
273
+ {
274
+ cwd: process.cwd(),
275
+ detached: true,
276
+ stdio: "inherit",
277
+ gid: process.getgid!(),
278
+ },
279
279
  );
280
- process.nextTick(async () => {
281
- await client.stop();
282
- await stopAndWait(server);
283
-
284
- // We filter out the reset command, since restarting means that we want to resume something
285
- spawn(
286
- process.argv.shift()!,
287
- [
288
- ...process.execArgv,
289
- ...process.argv.filter((x) => x !== "--reset" && x !== "-r"),
290
- ],
291
- {
292
- cwd: process.cwd(),
293
- detached: true,
294
- stdio: "inherit",
295
- gid: process.getgid!(),
296
- env: {
297
- ...process.env,
298
- NODE_PATH:
299
- (process.env.NODE_PATH
300
- ? process.env.NODE_PATH + path.delimiter
301
- : "") + (extraNodePath() ?? ""),
302
- },
303
- },
304
- );
305
- process.exit(0);
306
- });
280
+ process.exit(0);
307
281
  };
308
282
  if (!client.peerId.equals(await client.identity.publicKey.toPeerId())) {
309
283
  throw new Error("Expecting node identity to equal peerId");