java-caller 4.3.2 → 4.3.3

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.
Files changed (2) hide show
  1. package/lib/index.d.ts +203 -0
  2. package/package.json +5 -1
package/lib/index.d.ts ADDED
@@ -0,0 +1,203 @@
1
+
2
+ /* eslint-disable no-unused-vars */
3
+ /// <reference types="node" />
4
+
5
+ /**
6
+ * Options for JavaCaller constructor
7
+ */
8
+ export interface JavaCallerOptions {
9
+ /**
10
+ * Path to executable jar file
11
+ */
12
+ jar?: string;
13
+
14
+ /**
15
+ * If jar parameter is not set, classpath to use.
16
+ * Use : as separator (it will be converted if run on Windows), or use a string array.
17
+ */
18
+ classPath?: string | string[];
19
+
20
+ /**
21
+ * Set to true if classpaths should not be based on the rootPath
22
+ */
23
+ useAbsoluteClassPaths?: boolean;
24
+
25
+ /**
26
+ * If classPath set, main class to call
27
+ */
28
+ mainClass?: string;
29
+
30
+ /**
31
+ * Minimum java version to be used to call java command.
32
+ * If the java version found on machine is lower, java-caller will try to install and use the appropriate one
33
+ * @default 8 (11 on macOS)
34
+ */
35
+ minimumJavaVersion?: number;
36
+
37
+ /**
38
+ * Maximum java version to be used to call java command.
39
+ * If the java version found on machine is upper, java-caller will try to install and use the appropriate one
40
+ */
41
+ maximumJavaVersion?: number;
42
+
43
+ /**
44
+ * jre or jdk (if not defined and installation is required, jre will be installed)
45
+ */
46
+ javaType?: "jre" | "jdk";
47
+
48
+ /**
49
+ * If classPath elements are not relative to the current folder, you can define a root path.
50
+ * You may use __dirname if you classes / jars are in your module folder
51
+ * @default "." (current folder)
52
+ */
53
+ rootPath?: string;
54
+
55
+ /**
56
+ * You can force to use a defined java executable, instead of letting java-caller find/install one.
57
+ * Can also be defined with env var JAVA_CALLER_JAVA_EXECUTABLE
58
+ */
59
+ javaExecutable?: string;
60
+
61
+ /**
62
+ * Additional parameters for JVM that will be added in every JavaCaller instance runs
63
+ */
64
+ additionalJavaArgs?: string[];
65
+
66
+ /**
67
+ * Output mode: "none" or "console"
68
+ * @default "none"
69
+ */
70
+ output?: "none" | "console";
71
+ }
72
+
73
+ /**
74
+ * Options for JavaCaller run method
75
+ */
76
+ export interface JavaCallerRunOptions {
77
+ /**
78
+ * If set to true, node will not wait for the java command to be completed.
79
+ * In that case, childJavaProcess property will be returned, but stdout and stderr may be empty
80
+ * @default false
81
+ */
82
+ detached?: boolean;
83
+
84
+ /**
85
+ * Adds control on spawn process stdout
86
+ * @default "utf8"
87
+ */
88
+ stdoutEncoding?: string;
89
+
90
+ /**
91
+ * If detached is true, number of milliseconds to wait to detect an error before exiting JavaCaller run
92
+ * @default 500
93
+ */
94
+ waitForErrorMs?: number;
95
+
96
+ /**
97
+ * You can override cwd of spawn called by JavaCaller runner
98
+ * @default process.cwd()
99
+ */
100
+ cwd?: string;
101
+
102
+ /**
103
+ * List of arguments for JVM only, not the JAR or the class
104
+ */
105
+ javaArgs?: string[];
106
+
107
+ /**
108
+ * No quoting or escaping of arguments is done on Windows. Ignored on Unix.
109
+ * This is set to true automatically when shell is specified and is CMD.
110
+ * @default true
111
+ */
112
+ windowsVerbatimArguments?: boolean;
113
+
114
+ /**
115
+ * If windowless is true, JavaCaller calls javaw instead of java to not create any windows,
116
+ * useful when using detached on Windows. Ignored on Unix.
117
+ * @default false
118
+ */
119
+ windowless?: boolean;
120
+ }
121
+
122
+ /**
123
+ * Result returned by JavaCaller run method
124
+ */
125
+ export interface JavaCallerResult {
126
+ /**
127
+ * Exit status code of the java command
128
+ */
129
+ status: number | null;
130
+
131
+ /**
132
+ * Standard output of the java command
133
+ */
134
+ stdout: string;
135
+
136
+ /**
137
+ * Standard error output of the java command
138
+ */
139
+ stderr: string;
140
+
141
+ /**
142
+ * Child process object (useful when detached is true)
143
+ */
144
+ childJavaProcess?: import('child_process').ChildProcess;
145
+ }
146
+
147
+ /**
148
+ * JavaCaller class for calling Java commands from Node.js
149
+ */
150
+ export class JavaCaller {
151
+ minimumJavaVersion: number;
152
+ maximumJavaVersion?: number;
153
+ javaType?: "jre" | "jdk";
154
+ rootPath: string;
155
+ jar?: string;
156
+ classPath: string | string[];
157
+ useAbsoluteClassPaths: boolean;
158
+ mainClass?: string;
159
+ output: string;
160
+ status: number | null;
161
+ javaSupportDir?: string;
162
+ javaExecutable: string;
163
+ javaExecutableWindowless: string;
164
+ additionalJavaArgs: string[];
165
+ commandJavaArgs: string[];
166
+ javaHome?: string;
167
+ javaBin?: string;
168
+ javaExecutableFromNodeJavaCaller?: string | null;
169
+ prevPath?: string;
170
+ prevJavaHome?: string;
171
+
172
+ /**
173
+ * Creates a JavaCaller instance
174
+ * @param opts - Run options
175
+ */
176
+ constructor(opts: JavaCallerOptions);
177
+
178
+ /**
179
+ * Runs java command of a JavaCaller instance
180
+ * @param userArguments - Java command line arguments
181
+ * @param runOptions - Run options
182
+ * @returns Command result (status, stdout, stderr, childJavaProcess)
183
+ */
184
+ run(userArguments?: string[], runOptions?: JavaCallerRunOptions): Promise<JavaCallerResult>;
185
+ }
186
+
187
+ /**
188
+ * JavaCallerCli class for using java-caller from command line
189
+ */
190
+ export class JavaCallerCli {
191
+ javaCallerOptions: JavaCallerOptions;
192
+
193
+ /**
194
+ * Creates a JavaCallerCli instance
195
+ * @param baseDir - Base directory containing java-caller-config.json
196
+ */
197
+ constructor(baseDir: string);
198
+
199
+ /**
200
+ * Process command line arguments and run java command
201
+ */
202
+ process(): Promise<void>;
203
+ }
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "java-caller",
3
- "version": "4.3.2",
3
+ "version": "4.3.3",
4
4
  "description": "Library to easily call java from node sources. Automatically installs java if not present",
5
5
  "main": "./lib/index.js",
6
+ "types": "./lib/index.d.ts",
6
7
  "files": [
7
8
  "lib/"
8
9
  ],
@@ -26,6 +27,7 @@
26
27
  "node",
27
28
  "npm",
28
29
  "javascript",
30
+ "typescript",
29
31
  "class"
30
32
  ],
31
33
  "author": "Nicolas Vuillamy",
@@ -42,10 +44,12 @@
42
44
  },
43
45
  "devDependencies": {
44
46
  "@babel/eslint-parser": "^7.22.15",
47
+ "@types/node": "^25.2.0",
45
48
  "eslint": "^9.0.0",
46
49
  "mocha": "^11.0.0",
47
50
  "nyc": "^17.0.0",
48
51
  "prettier": "^3.1.0",
52
+ "typescript": "^5.9.3",
49
53
  "which": "^6.0.0"
50
54
  },
51
55
  "engines": {