@deltachat/stdio-rpc-server 1.139.2 → 1.139.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -46,12 +46,11 @@ references:
46
46
  When you import this package it searches for the rpc server in the following locations and order:
47
47
 
48
48
  1. `DELTA_CHAT_RPC_SERVER` environment variable
49
- 2. in PATH
50
- - unless `DELTA_CHAT_SKIP_PATH=1` is specified
51
- - searches in .cargo/bin directory first
52
- - but there an additional version check is performed
49
+ 2. use the PATH when `{takeVersionFromPATH: true}` is supplied in the options.
53
50
  3. prebuilds in npm packages
54
51
 
52
+ so by default it uses the prebuilds.
53
+
55
54
  ## How do you built this package in CI
56
55
 
57
56
  - To build platform packages, run the `build_platform_package.py` script:
package/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import { StdioDeltaChat } from "@deltachat/jsonrpc-client";
2
2
 
3
3
  export interface SearchOptions {
4
- /** whether to disable looking for deltachat-rpc-server inside of $PATH */
5
- skipSearchInPath: boolean;
4
+ /** whether take deltachat-rpc-server inside of $PATH*/
5
+ takeVersionFromPATH: boolean;
6
6
 
7
7
  /** whether to disable the DELTA_CHAT_RPC_SERVER environment variable */
8
8
  disableEnvPath: boolean;
package/index.js CHANGED
@@ -1,15 +1,9 @@
1
1
  //@ts-check
2
- import { execFile, spawn } from "node:child_process";
3
- import { stat, readdir } from "node:fs/promises";
2
+ import { spawn } from "node:child_process";
3
+ import { stat } from "node:fs/promises";
4
4
  import os from "node:os";
5
- import { join, basename } from "node:path";
6
5
  import process from "node:process";
7
- import { promisify } from "node:util";
8
- import {
9
- ENV_VAR_NAME,
10
- PATH_EXECUTABLE_NAME,
11
- SKIP_SEARCH_IN_PATH,
12
- } from "./src/const.js";
6
+ import { ENV_VAR_NAME, PATH_EXECUTABLE_NAME } from "./src/const.js";
13
7
  import {
14
8
  ENV_VAR_LOCATION_NOT_FOUND,
15
9
  FAILED_TO_START_SERVER_EXECUTABLE,
@@ -39,38 +33,13 @@ function findRPCServerInNodeModules() {
39
33
  }
40
34
  }
41
35
 
42
- /**
43
- * @returns {Promise<string>}
44
- */
45
- async function getLocationInPath() {
46
- const exec = promisify(execFile);
47
-
48
- if (os.platform() === "win32") {
49
- const { stdout: executable } = await exec("where", [PATH_EXECUTABLE_NAME], {
50
- shell: true,
51
- });
52
- return executable;
53
- }
54
-
55
- try {
56
- const { stdout: executable } = await exec(
57
- "command",
58
- ["-v", PATH_EXECUTABLE_NAME],
59
- { shell: true }
60
- );
61
- return executable;
62
- } catch (error) {
63
- if (error.code > 0) return "";
64
- else throw error;
65
- }
66
- }
67
-
68
36
  /** @type {import("./index").FnTypes.getRPCServerPath} */
69
- export async function getRPCServerPath(
70
- options = { skipSearchInPath: false, disableEnvPath: false }
71
- ) {
72
- // @TODO: improve confusing naming of these options
73
- const { skipSearchInPath, disableEnvPath } = options;
37
+ export async function getRPCServerPath(options = {}) {
38
+ const { takeVersionFromPATH, disableEnvPath } = {
39
+ takeVersionFromPATH: false,
40
+ disableEnvPath: false,
41
+ ...options,
42
+ };
74
43
  // 1. check if it is set as env var
75
44
  if (process.env[ENV_VAR_NAME] && !disableEnvPath) {
76
45
  try {
@@ -85,35 +54,9 @@ export async function getRPCServerPath(
85
54
  return process.env[ENV_VAR_NAME];
86
55
  }
87
56
 
88
- // 2. check if it can be found in PATH
89
- if (!process.env[SKIP_SEARCH_IN_PATH] && !skipSearchInPath) {
90
- const executable = await getLocationInPath();
91
-
92
- // by just trying to execute it and then use "command -v deltachat-rpc-server" (unix) or "where deltachat-rpc-server" (windows) to get the path to the executable
93
- if (executable.length > 1) {
94
- // test if it is the right version
95
- try {
96
- // for some unknown reason it is in stderr and not in stdout
97
- const { stderr } = await promisify(execFile)(
98
- executable,
99
- ["--version"],
100
- { shell: true }
101
- );
102
- const version = stderr.slice(0, stderr.indexOf("\n"));
103
- if (package_json.version !== version) {
104
- throw new Error(
105
- `version mismatch: (npm package: ${package_json.version}) (installed ${PATH_EXECUTABLE_NAME} version: ${version})`
106
- );
107
- } else {
108
- return executable;
109
- }
110
- } catch (error) {
111
- console.error(
112
- "Found executable in PATH, but there was an error: " + error
113
- );
114
- console.error("So falling back to using prebuild...");
115
- }
116
- }
57
+ // 2. check if PATH should be used
58
+ if (takeVersionFromPATH) {
59
+ return PATH_EXECUTABLE_NAME;
117
60
  }
118
61
  // 3. check for prebuilds
119
62
 
@@ -123,7 +66,7 @@ export async function getRPCServerPath(
123
66
  import { StdioDeltaChat } from "@deltachat/jsonrpc-client";
124
67
 
125
68
  /** @type {import("./index").FnTypes.startDeltaChat} */
126
- export async function startDeltaChat(directory, options) {
69
+ export async function startDeltaChat(directory, options = {}) {
127
70
  const pathToServerBinary = await getRPCServerPath(options);
128
71
  const server = spawn(pathToServerBinary, {
129
72
  env: {
package/package.json CHANGED
@@ -3,16 +3,16 @@
3
3
  "main": "index.js",
4
4
  "name": "@deltachat/stdio-rpc-server",
5
5
  "optionalDependencies": {
6
- "@deltachat/stdio-rpc-server-darwin-arm64": "1.139.2",
7
- "@deltachat/stdio-rpc-server-android-arm64": "1.139.2",
8
- "@deltachat/stdio-rpc-server-linux-arm64": "1.139.2",
9
- "@deltachat/stdio-rpc-server-linux-arm": "1.139.2",
10
- "@deltachat/stdio-rpc-server-android-arm": "1.139.2",
11
- "@deltachat/stdio-rpc-server-win32-ia32": "1.139.2",
12
- "@deltachat/stdio-rpc-server-linux-ia32": "1.139.2",
13
- "@deltachat/stdio-rpc-server-darwin-x64": "1.139.2",
14
- "@deltachat/stdio-rpc-server-win32-x64": "1.139.2",
15
- "@deltachat/stdio-rpc-server-linux-x64": "1.139.2"
6
+ "@deltachat/stdio-rpc-server-darwin-arm64": "1.139.4",
7
+ "@deltachat/stdio-rpc-server-android-arm64": "1.139.4",
8
+ "@deltachat/stdio-rpc-server-linux-arm64": "1.139.4",
9
+ "@deltachat/stdio-rpc-server-linux-arm": "1.139.4",
10
+ "@deltachat/stdio-rpc-server-android-arm": "1.139.4",
11
+ "@deltachat/stdio-rpc-server-win32-ia32": "1.139.4",
12
+ "@deltachat/stdio-rpc-server-linux-ia32": "1.139.4",
13
+ "@deltachat/stdio-rpc-server-darwin-x64": "1.139.4",
14
+ "@deltachat/stdio-rpc-server-win32-x64": "1.139.4",
15
+ "@deltachat/stdio-rpc-server-linux-x64": "1.139.4"
16
16
  },
17
17
  "peerDependencies": {
18
18
  "@deltachat/jsonrpc-client": "*"
@@ -26,5 +26,5 @@
26
26
  },
27
27
  "type": "module",
28
28
  "types": "index.d.ts",
29
- "version": "1.139.2"
29
+ "version": "1.139.4"
30
30
  }
package/src/const.js CHANGED
@@ -2,5 +2,4 @@
2
2
 
3
3
  export const PATH_EXECUTABLE_NAME = 'deltachat-rpc-server'
4
4
 
5
- export const ENV_VAR_NAME = "DELTA_CHAT_RPC_SERVER"
6
- export const SKIP_SEARCH_IN_PATH = "DELTA_CHAT_SKIP_PATH"
5
+ export const ENV_VAR_NAME = "DELTA_CHAT_RPC_SERVER"