@appium/support 7.0.5 → 7.0.6
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/LICENSE +201 -0
- package/build/lib/console.d.ts +42 -88
- package/build/lib/console.d.ts.map +1 -1
- package/build/lib/console.js +20 -80
- package/build/lib/console.js.map +1 -1
- package/build/lib/doctor.d.ts +6 -18
- package/build/lib/doctor.d.ts.map +1 -1
- package/build/lib/doctor.js +0 -15
- package/build/lib/doctor.js.map +1 -1
- package/build/lib/env.d.ts +14 -20
- package/build/lib/env.d.ts.map +1 -1
- package/build/lib/env.js +13 -50
- package/build/lib/env.js.map +1 -1
- package/build/lib/fs.d.ts +109 -148
- package/build/lib/fs.d.ts.map +1 -1
- package/build/lib/fs.js +88 -188
- package/build/lib/fs.js.map +1 -1
- package/build/lib/image-util.d.ts +7 -6
- package/build/lib/image-util.d.ts.map +1 -1
- package/build/lib/image-util.js +9 -6
- package/build/lib/image-util.js.map +1 -1
- package/build/lib/index.d.ts +19 -17
- package/build/lib/index.d.ts.map +1 -1
- package/build/lib/logger.d.ts +1 -1
- package/build/lib/logger.d.ts.map +1 -1
- package/build/lib/logger.js +1 -1
- package/build/lib/logger.js.map +1 -1
- package/build/lib/logging.d.ts +7 -15
- package/build/lib/logging.d.ts.map +1 -1
- package/build/lib/logging.js +36 -62
- package/build/lib/logging.js.map +1 -1
- package/build/lib/mjpeg.d.ts +19 -56
- package/build/lib/mjpeg.d.ts.map +1 -1
- package/build/lib/mjpeg.js +53 -76
- package/build/lib/mjpeg.js.map +1 -1
- package/build/lib/mkdirp.d.ts +4 -1
- package/build/lib/mkdirp.d.ts.map +1 -1
- package/build/lib/mkdirp.js +1 -2
- package/build/lib/mkdirp.js.map +1 -1
- package/build/lib/net.d.ts +52 -90
- package/build/lib/net.d.ts.map +1 -1
- package/build/lib/net.js +104 -193
- package/build/lib/net.js.map +1 -1
- package/build/lib/node.d.ts +16 -17
- package/build/lib/node.d.ts.map +1 -1
- package/build/lib/node.js +106 -111
- package/build/lib/node.js.map +1 -1
- package/build/lib/npm.d.ts +65 -86
- package/build/lib/npm.d.ts.map +1 -1
- package/build/lib/npm.js +59 -117
- package/build/lib/npm.js.map +1 -1
- package/build/lib/plist.d.ts +36 -29
- package/build/lib/plist.d.ts.map +1 -1
- package/build/lib/plist.js +62 -59
- package/build/lib/plist.js.map +1 -1
- package/build/lib/process.d.ts +19 -2
- package/build/lib/process.d.ts.map +1 -1
- package/build/lib/process.js +24 -7
- package/build/lib/process.js.map +1 -1
- package/build/lib/system.d.ts +41 -6
- package/build/lib/system.d.ts.map +1 -1
- package/build/lib/system.js +46 -11
- package/build/lib/system.js.map +1 -1
- package/build/lib/tempdir.d.ts +26 -49
- package/build/lib/tempdir.d.ts.map +1 -1
- package/build/lib/tempdir.js +41 -73
- package/build/lib/tempdir.js.map +1 -1
- package/build/lib/timing.d.ts +28 -22
- package/build/lib/timing.d.ts.map +1 -1
- package/build/lib/timing.js +16 -17
- package/build/lib/timing.js.map +1 -1
- package/build/lib/util.d.ts +164 -181
- package/build/lib/util.d.ts.map +1 -1
- package/build/lib/util.js +193 -247
- package/build/lib/util.js.map +1 -1
- package/build/lib/zip.d.ts +81 -139
- package/build/lib/zip.d.ts.map +1 -1
- package/build/lib/zip.js +210 -258
- package/build/lib/zip.js.map +1 -1
- package/lib/console.ts +139 -0
- package/lib/{doctor.js → doctor.ts} +6 -20
- package/lib/{env.js → env.ts} +31 -59
- package/lib/fs.ts +453 -0
- package/lib/image-util.ts +40 -0
- package/lib/index.ts +1 -0
- package/lib/{logger.js → logger.ts} +1 -1
- package/lib/logging.ts +157 -0
- package/lib/mjpeg.ts +186 -0
- package/lib/{mkdirp.js → mkdirp.ts} +2 -2
- package/lib/net.ts +305 -0
- package/lib/{node.js → node.ts} +134 -133
- package/lib/npm.ts +291 -0
- package/lib/plist.ts +187 -0
- package/lib/process.ts +62 -0
- package/lib/system.ts +95 -0
- package/lib/tempdir.ts +115 -0
- package/lib/{timing.js → timing.ts} +28 -33
- package/lib/util.ts +561 -0
- package/lib/{zip.js → zip.ts} +341 -296
- package/package.json +20 -22
- package/tsconfig.json +3 -5
- package/index.js +0 -1
- package/lib/console.js +0 -173
- package/lib/fs.js +0 -496
- package/lib/image-util.js +0 -32
- package/lib/logging.js +0 -145
- package/lib/mjpeg.js +0 -207
- package/lib/net.js +0 -336
- package/lib/npm.js +0 -310
- package/lib/plist.js +0 -182
- package/lib/process.js +0 -46
- package/lib/system.js +0 -48
- package/lib/tempdir.js +0 -131
- package/lib/util.js +0 -584
package/build/lib/plist.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plist.js","sourceRoot":"","sources":["../../lib/plist.
|
|
1
|
+
{"version":3,"file":"plist.js","sourceRoot":"","sources":["../../lib/plist.ts"],"names":[],"mappings":";;;;;AAwBA,wCAuCC;AAWD,0CAuBC;AAQD,8CAEC;AAQD,4CAEC;AASD,kCAKC;AASD,gCAcC;AA1JD,kDAA6B;AAC7B,oEAA0C;AAC1C,iDAAqD;AACrD,6BAAwB;AACxB,sDAA2B;AAC3B,oDAAuB;AAEvB,MAAM,iBAAiB,GAAG;IACxB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC;IAC/B,IAAI,EAAE,UAAU;CACjB,CAAC;AACF,MAAM,gBAAgB,GAAG;IACvB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;IACxB,IAAI,EAAE,GAAG;CACV,CAAC;AAEF;;;;;;;GAOG;AACI,KAAK,UAAU,cAAc,CAClC,KAAa,EACb,SAAS,GAAG,IAAI,EAChB,KAAK,GAAG,IAAI;IAEZ,IAAI,CAAC,CAAC,MAAM,OAAE,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC;QAC9B,IAAI,SAAS,EAAE,CAAC;YACd,MAAM,gBAAG,CAAC,kBAAkB,CAAC,8BAA8B,KAAK,GAAG,CAAC,CAAC;QACvE,C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B,CAAC;IAED,IACE,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;QACrB,iBAAiB,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC,EAAE,iBAAiB,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAChF,CAAC;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/build/lib/process.d.ts
CHANGED
|
@@ -1,3 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Get PIDs of processes whose executable name matches the given name (exact match via pgrep -x).
|
|
3
|
+
*
|
|
4
|
+
* @param appName - Executable name to match (e.g. 'tail', 'node').
|
|
5
|
+
* @returns Promise resolving to an array of process IDs. Empty if no processes matched.
|
|
6
|
+
* @throws {Error} If pgrep fails for any reason other than "no processes matched" (exit 1).
|
|
7
|
+
* @deprecated Use a process-management API or package that fits your platform instead.
|
|
8
|
+
*/
|
|
9
|
+
export declare function getProcessIds(appName: string): Promise<number[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Kill all processes whose executable name matches the given name (via pkill -x).
|
|
12
|
+
*
|
|
13
|
+
* @param appName - Executable name to match (e.g. 'tail', 'node').
|
|
14
|
+
* @param force - If true, use SIGKILL (-9); otherwise use default pkill signal.
|
|
15
|
+
* @returns Promise that resolves when done, or when no matching processes were running.
|
|
16
|
+
* @throws {Error} If pkill fails for any reason other than "no processes matched" (exit 1).
|
|
17
|
+
* @deprecated Use a process-management API or package that fits your platform instead.
|
|
18
|
+
*/
|
|
19
|
+
export declare function killProcess(appName: string, force?: boolean): Promise<void>;
|
|
3
20
|
//# sourceMappingURL=process.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../lib/process.
|
|
1
|
+
{"version":3,"file":"process.d.ts","sourceRoot":"","sources":["../../lib/process.ts"],"names":[],"mappings":"AAWA;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAgBtE;AAED;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,UAAQ,GAAG,OAAO,CAAC,IAAI,CAAC,CAe/E"}
|
package/build/lib/process.js
CHANGED
|
@@ -10,36 +10,53 @@ const teen_process_1 = require("teen_process");
|
|
|
10
10
|
* 2. Syntax error in the command line.
|
|
11
11
|
* 3. Fatal error: out of memory etc.
|
|
12
12
|
*/
|
|
13
|
+
/**
|
|
14
|
+
* Get PIDs of processes whose executable name matches the given name (exact match via pgrep -x).
|
|
15
|
+
*
|
|
16
|
+
* @param appName - Executable name to match (e.g. 'tail', 'node').
|
|
17
|
+
* @returns Promise resolving to an array of process IDs. Empty if no processes matched.
|
|
18
|
+
* @throws {Error} If pgrep fails for any reason other than "no processes matched" (exit 1).
|
|
19
|
+
* @deprecated Use a process-management API or package that fits your platform instead.
|
|
20
|
+
*/
|
|
13
21
|
async function getProcessIds(appName) {
|
|
14
22
|
let pids;
|
|
15
23
|
try {
|
|
16
|
-
|
|
24
|
+
const { stdout } = await (0, teen_process_1.exec)('pgrep', ['-x', appName]);
|
|
17
25
|
pids = stdout
|
|
18
26
|
.trim()
|
|
19
27
|
.split('\n')
|
|
20
28
|
.map((pid) => parseInt(pid, 10));
|
|
21
29
|
}
|
|
22
30
|
catch (err) {
|
|
23
|
-
|
|
31
|
+
const code = err.code;
|
|
32
|
+
if (code !== 1) {
|
|
24
33
|
throw new Error(`Error getting process ids for app '${appName}': ${err.message}`);
|
|
25
34
|
}
|
|
26
35
|
pids = [];
|
|
27
36
|
}
|
|
28
37
|
return pids;
|
|
29
38
|
}
|
|
39
|
+
/**
|
|
40
|
+
* Kill all processes whose executable name matches the given name (via pkill -x).
|
|
41
|
+
*
|
|
42
|
+
* @param appName - Executable name to match (e.g. 'tail', 'node').
|
|
43
|
+
* @param force - If true, use SIGKILL (-9); otherwise use default pkill signal.
|
|
44
|
+
* @returns Promise that resolves when done, or when no matching processes were running.
|
|
45
|
+
* @throws {Error} If pkill fails for any reason other than "no processes matched" (exit 1).
|
|
46
|
+
* @deprecated Use a process-management API or package that fits your platform instead.
|
|
47
|
+
*/
|
|
30
48
|
async function killProcess(appName, force = false) {
|
|
31
|
-
|
|
49
|
+
const pids = await getProcessIds(appName);
|
|
32
50
|
if (pids.length === 0) {
|
|
33
|
-
// the process is not running
|
|
34
51
|
return;
|
|
35
52
|
}
|
|
36
53
|
try {
|
|
37
|
-
|
|
38
|
-
args.push('-x', appName);
|
|
54
|
+
const args = force ? ['-9', '-x', appName] : ['-x', appName];
|
|
39
55
|
await (0, teen_process_1.exec)('pkill', args);
|
|
40
56
|
}
|
|
41
57
|
catch (err) {
|
|
42
|
-
|
|
58
|
+
const code = err.code;
|
|
59
|
+
if (code !== 1) {
|
|
43
60
|
throw new Error(`Error killing app '${appName}' with pkill: ${err.message}`);
|
|
44
61
|
}
|
|
45
62
|
}
|
package/build/lib/process.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../lib/process.
|
|
1
|
+
{"version":3,"file":"process.js","sourceRoot":"","sources":["../../lib/process.ts"],"names":[],"mappings":";;AAmBA,sCAgBC;AAWD,kCAeC;AA7DD,+CAAkC;AAGlC;;;;;;GAMG;AAEH;;;;;;;GAOG;AACI,KAAK,UAAU,aAAa,CAAC,OAAe;IACjD,IAAI,IAAc,CAAC;IACnB,IAAI,CAAC;QACH,MAAM,EAAC,MAAM,EAAC,GAAG,MAAM,IAAA,mBAAI,EAAC,OAAO,EAAE,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC,CAAC;QACtD,IAAI,GAAG,MAAM;aACV,IAAI,EAAE;aACN,KAAK,CAAC,IAAI,CAAC;aACX,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE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function isWindows(): boolean;
|
|
5
|
+
/**
|
|
6
|
+
* Whether the current OS is macOS (Darwin).
|
|
7
|
+
*/
|
|
8
|
+
export declare function isMac(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Whether the current OS is Linux (i.e. not Windows and not macOS).
|
|
11
|
+
*/
|
|
12
|
+
export declare function isLinux(): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Whether the current Windows process is 64-bit (or WOW64).
|
|
15
|
+
*/
|
|
16
|
+
export declare function isOSWin64(): boolean;
|
|
17
|
+
/**
|
|
18
|
+
* Detects the major.minor macOS version (e.g. "10.12") via `sw_vers -productVersion`.
|
|
19
|
+
*
|
|
20
|
+
* @returns The major.minor version string.
|
|
21
|
+
* @throws {Error} If `sw_vers` fails or output cannot be parsed.
|
|
22
|
+
*/
|
|
23
|
+
export declare function macOsxVersion(): Promise<string>;
|
|
24
|
+
/**
|
|
25
|
+
* System detection helpers (platform, architecture, macOS version).
|
|
26
|
+
* Use this object when you need `arch()` to call other helpers via `this` (e.g. for testing).
|
|
27
|
+
*/
|
|
28
|
+
export declare const system: System;
|
|
29
|
+
/**
|
|
30
|
+
* Resolves the process architecture as `'32'` or `'64'` (uname on Unix, process.arch/env on Windows).
|
|
31
|
+
*/
|
|
32
|
+
export declare const arch: () => Promise<string>;
|
|
33
|
+
interface System {
|
|
34
|
+
isWindows(): boolean;
|
|
35
|
+
isMac(): boolean;
|
|
36
|
+
isLinux(): boolean;
|
|
37
|
+
isOSWin64(): boolean;
|
|
38
|
+
arch(): Promise<string>;
|
|
39
|
+
macOsxVersion(): Promise<string>;
|
|
40
|
+
}
|
|
41
|
+
export {};
|
|
7
42
|
//# sourceMappingURL=system.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../lib/system.
|
|
1
|
+
{"version":3,"file":"system.d.ts","sourceRoot":"","sources":["../../lib/system.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;GAEG;AACH,wBAAgB,KAAK,IAAI,OAAO,CAE/B;AAED;;GAEG;AACH,wBAAgB,OAAO,IAAI,OAAO,CAEjC;AAED;;GAEG;AACH,wBAAgB,SAAS,IAAI,OAAO,CAEnC;AAED;;;;;GAKG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAarD;AAED;;;GAGG;AACH,eAAO,MAAM,MAAM,EAAE,MAOpB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,IAAI,QASP,OAAO,CAAC,MAAM,CAAC,AATM,CAAC;AAIhC,UAAU,MAAM;IACd,SAAS,IAAI,OAAO,CAAC;IACrB,KAAK,IAAI,OAAO,CAAC;IACjB,OAAO,IAAI,OAAO,CAAC;IACnB,SAAS,IAAI,OAAO,CAAC;IACrB,IAAI,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IACxB,aAAa,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAClC"}
|
package/build/lib/system.js
CHANGED
|
@@ -3,38 +3,46 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.arch = exports.system = void 0;
|
|
6
7
|
exports.isWindows = isWindows;
|
|
7
8
|
exports.isMac = isMac;
|
|
8
9
|
exports.isLinux = isLinux;
|
|
9
10
|
exports.isOSWin64 = isOSWin64;
|
|
10
|
-
exports.arch = arch;
|
|
11
11
|
exports.macOsxVersion = macOsxVersion;
|
|
12
12
|
const teen_process_1 = require("teen_process");
|
|
13
13
|
const lodash_1 = __importDefault(require("lodash"));
|
|
14
14
|
const node_os_1 = __importDefault(require("node:os"));
|
|
15
15
|
const VERSION_PATTERN = /^(\d+\.\d+)/m;
|
|
16
|
+
/**
|
|
17
|
+
* Whether the current OS is Windows.
|
|
18
|
+
*/
|
|
16
19
|
function isWindows() {
|
|
17
20
|
return node_os_1.default.type() === 'Windows_NT';
|
|
18
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Whether the current OS is macOS (Darwin).
|
|
24
|
+
*/
|
|
19
25
|
function isMac() {
|
|
20
26
|
return node_os_1.default.type() === 'Darwin';
|
|
21
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* Whether the current OS is Linux (i.e. not Windows and not macOS).
|
|
30
|
+
*/
|
|
22
31
|
function isLinux() {
|
|
23
32
|
return !isWindows() && !isMac();
|
|
24
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Whether the current Windows process is 64-bit (or WOW64).
|
|
36
|
+
*/
|
|
25
37
|
function isOSWin64() {
|
|
26
38
|
return process.arch === 'x64' || lodash_1.default.has(process.env, 'PROCESSOR_ARCHITEW6432');
|
|
27
39
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
let is64 = this.isOSWin64();
|
|
35
|
-
return is64 ? '64' : '32';
|
|
36
|
-
}
|
|
37
|
-
}
|
|
40
|
+
/**
|
|
41
|
+
* Detects the major.minor macOS version (e.g. "10.12") via `sw_vers -productVersion`.
|
|
42
|
+
*
|
|
43
|
+
* @returns The major.minor version string.
|
|
44
|
+
* @throws {Error} If `sw_vers` fails or output cannot be parsed.
|
|
45
|
+
*/
|
|
38
46
|
async function macOsxVersion() {
|
|
39
47
|
let stdout;
|
|
40
48
|
try {
|
|
@@ -49,4 +57,31 @@ async function macOsxVersion() {
|
|
|
49
57
|
}
|
|
50
58
|
return versionMatch[1];
|
|
51
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* System detection helpers (platform, architecture, macOS version).
|
|
62
|
+
* Use this object when you need `arch()` to call other helpers via `this` (e.g. for testing).
|
|
63
|
+
*/
|
|
64
|
+
exports.system = {
|
|
65
|
+
isWindows,
|
|
66
|
+
isMac,
|
|
67
|
+
isLinux,
|
|
68
|
+
isOSWin64,
|
|
69
|
+
arch: archImpl,
|
|
70
|
+
macOsxVersion,
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* Resolves the process architecture as `'32'` or `'64'` (uname on Unix, process.arch/env on Windows).
|
|
74
|
+
*/
|
|
75
|
+
exports.arch = exports.system.arch;
|
|
76
|
+
async function archImpl() {
|
|
77
|
+
if (this.isLinux() || this.isMac()) {
|
|
78
|
+
const { stdout } = await (0, teen_process_1.exec)('uname', ['-m']);
|
|
79
|
+
return stdout.trim() === 'i686' ? '32' : '64';
|
|
80
|
+
}
|
|
81
|
+
else if (this.isWindows()) {
|
|
82
|
+
return this.isOSWin64() ? '64' : '32';
|
|
83
|
+
}
|
|
84
|
+
return '64';
|
|
85
|
+
}
|
|
86
|
+
// #endregion
|
|
52
87
|
//# sourceMappingURL=system.js.map
|
package/build/lib/system.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../lib/system.
|
|
1
|
+
{"version":3,"file":"system.js","sourceRoot":"","sources":["../../lib/system.ts"],"names":[],"mappings":";;;;;;AASA,8BAEC;AAKD,sBAEC;AAKD,0BAEC;AAKD,8BAEC;AAQD,sCAaC;AArDD,+CAAkC;AAClC,oDAAuB;AACvB,sDAAyB;AAEzB,MAAM,eAAe,GAAG,cAAc,CAAC;AAEvC;;GAEG;AACH,SAAgB,SAAS;IACvB,OAAO,iBAAE,CAAC,IAAI,EAAE,KAAK,YAAY,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,SAAgB,KAAK;IACnB,OAAO,iBAAE,CAAC,IAAI,EAAE,KAAK,QAAQ,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,SAAgB,OAAO;IACrB,OAAO,CAAC,SAAS,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,SAAgB,SAAS;IACvB,OAAO,OAAO,CAAC,IAAI,KAAK,KAAK,IAAI,gBAAC,CAAC,G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AC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;IACxC,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC;AAED,aAAa"}
|
package/build/lib/tempdir.d.ts
CHANGED
|
@@ -1,63 +1,40 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
suffix?: string | undefined;
|
|
10
|
-
};
|
|
11
|
-
export type OpenedAffixes = {
|
|
12
|
-
/**
|
|
13
|
-
* - The path to file
|
|
14
|
-
*/
|
|
1
|
+
import _ from 'lodash';
|
|
2
|
+
/** Prefix/suffix for temp directory or file names */
|
|
3
|
+
export interface Affixes {
|
|
4
|
+
prefix?: string;
|
|
5
|
+
suffix?: string;
|
|
6
|
+
}
|
|
7
|
+
/** Result of opening a temp file */
|
|
8
|
+
export interface OpenedAffixes {
|
|
15
9
|
path: string;
|
|
16
|
-
/**
|
|
17
|
-
* - The file descriptor opened
|
|
18
|
-
*/
|
|
19
10
|
fd: number;
|
|
20
|
-
}
|
|
11
|
+
}
|
|
21
12
|
/**
|
|
22
|
-
*
|
|
23
|
-
* @property {string} path - The path to file
|
|
24
|
-
* @property {number} fd - The file descriptor opened
|
|
25
|
-
*/
|
|
26
|
-
/**
|
|
27
|
-
* Generate a temporary directory in os.tempdir() or process.env.APPIUM_TMP_DIR
|
|
28
|
-
* with arbitrary prefix/suffix for the directory name and return it as open.
|
|
13
|
+
* Generate a temporary directory with arbitrary prefix/suffix for the directory name.
|
|
29
14
|
*
|
|
30
|
-
* @param
|
|
31
|
-
* @
|
|
15
|
+
* @param rawAffixes - Prefix string, or object with prefix/suffix, or omitted.
|
|
16
|
+
* @param defaultPrefix - Default prefix when rawAffixes is omitted.
|
|
17
|
+
* @returns A path to the temporary directory.
|
|
32
18
|
*/
|
|
33
|
-
export function
|
|
19
|
+
export declare function path(rawAffixes?: string | Affixes, defaultPrefix?: string): Promise<string>;
|
|
34
20
|
/**
|
|
35
|
-
*
|
|
36
|
-
* @property {string} [prefix] - prefix of the temp directory name
|
|
37
|
-
* @property {string} [suffix] - suffix of the temp directory name
|
|
38
|
-
*/
|
|
39
|
-
/**
|
|
40
|
-
* Generate a temporary directory in os.tempdir() or process.env.APPIUM_TMP_DIR
|
|
41
|
-
* with arbitrary prefix/suffix for the directory name.
|
|
21
|
+
* Generate a temp file path with prefix/suffix, open the file, and return path and fd.
|
|
42
22
|
*
|
|
43
|
-
* @param
|
|
44
|
-
* @
|
|
45
|
-
* @returns {Promise<string>} A path to the temporary directory with rawAffixes and defaultPrefix
|
|
23
|
+
* @param affixes - Prefix/suffix for the file name.
|
|
24
|
+
* @returns The opened file path and descriptor.
|
|
46
25
|
*/
|
|
47
|
-
export function
|
|
26
|
+
export declare function open(affixes: Affixes): Promise<OpenedAffixes>;
|
|
27
|
+
/** Returns a new path to a temporary directory (alias for the tempDir implementation). */
|
|
28
|
+
export declare const openDir: typeof tempDir;
|
|
48
29
|
/**
|
|
49
|
-
*
|
|
50
|
-
* e.g.
|
|
51
|
-
* - No `process.env.APPIUM_TMP_DIR`: `/var/folders/34/2222sh8n27d6rcp7jqlkw8km0000gn/T/xxxxxxxx.yyyy`
|
|
52
|
-
* - With `process.env.APPIUM_TMP_DIR = '/path/to/root'`: `/path/to/root/xxxxxxxx.yyyy`
|
|
30
|
+
* Returns a path to a temporary directory which is reused for the life of the process.
|
|
53
31
|
*
|
|
54
|
-
* @returns
|
|
32
|
+
* @returns The same temp directory path on every call.
|
|
55
33
|
*/
|
|
56
|
-
export
|
|
34
|
+
export declare const staticDir: (() => Promise<string>) & _.MemoizedFunction;
|
|
57
35
|
/**
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
* @returns {Promise<string>} A temp directory path which is defined as static in the same process
|
|
36
|
+
* Generate a temporary directory in os.tmpdir() or process.env.APPIUM_TMP_DIR.
|
|
61
37
|
*/
|
|
62
|
-
|
|
38
|
+
declare function tempDir(): Promise<string>;
|
|
39
|
+
export {};
|
|
63
40
|
//# sourceMappingURL=tempdir.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tempdir.d.ts","sourceRoot":"","sources":["../../lib/tempdir.
|
|
1
|
+
{"version":3,"file":"tempdir.d.ts","sourceRoot":"","sources":["../../lib/tempdir.ts"],"names":[],"mappings":"AAIA,OAAO,CAAC,MAAM,QAAQ,CAAC;AAMvB,qDAAqD;AACrD,MAAM,WAAW,OAAO;IACtB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,oCAAoC;AACpC,MAAM,WAAW,aAAa;IAC5B,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,EAAE,MAAM,CAAC;CACZ;AAED;;;;;;GAMG;AACH,wBAAsB,IAAI,CACxB,UAAU,CAAC,EAAE,MAAM,GAAG,OAAO,EAC7B,aAAa,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,CAAC,CAKjB;AAED;;;;;GAKG;AACH,wBAAsB,IAAI,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,aAAa,CAAC,CAQnE;AAED,0FAA0F;AAC1F,eAAO,MAAM,OAAO,gBAAU,CAAC;AAE/B;;;;GAIG;AACH,eAAO,MAAM,SAAS,SAA0C,OAAO,CAAC,MAAM,CAAC,sBAE7E,CAAC;AAIH;;GAEG;AACH,iBAAe,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,CAkBxC"}
|
package/build/lib/tempdir.js
CHANGED
|
@@ -3,103 +3,86 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.openDir = void 0;
|
|
7
|
-
exports.open = open;
|
|
6
|
+
exports.staticDir = exports.openDir = void 0;
|
|
8
7
|
exports.path = path;
|
|
9
|
-
exports.
|
|
8
|
+
exports.open = open;
|
|
10
9
|
/* This library is originated from temp.js at http://github.com/bruce/node-temp */
|
|
11
10
|
const fs_1 = require("./fs");
|
|
12
11
|
const node_os_1 = __importDefault(require("node:os"));
|
|
13
12
|
const node_path_1 = __importDefault(require("node:path"));
|
|
13
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
14
14
|
const node_fs_1 = require("node:fs");
|
|
15
15
|
const logger_1 = __importDefault(require("./logger"));
|
|
16
16
|
const RDWR_EXCL = node_fs_1.constants.O_CREAT | node_fs_1.constants.O_TRUNC | node_fs_1.constants.O_RDWR | node_fs_1.constants.O_EXCL;
|
|
17
17
|
/**
|
|
18
|
-
* Generate a temporary directory
|
|
19
|
-
* e.g.
|
|
20
|
-
* - No `process.env.APPIUM_TMP_DIR`: `/var/folders/34/2222sh8n27d6rcp7jqlkw8km0000gn/T/xxxxxxxx.yyyy`
|
|
21
|
-
* - With `process.env.APPIUM_TMP_DIR = '/path/to/root'`: `/path/to/root/xxxxxxxx.yyyy`
|
|
22
|
-
*
|
|
23
|
-
* @returns {Promise<string>} A path to the temporary directory
|
|
24
|
-
*/
|
|
25
|
-
async function tempDir() {
|
|
26
|
-
const now = new Date();
|
|
27
|
-
const filePath = node_path_1.default.join(process.env.APPIUM_TMP_DIR || node_os_1.default.tmpdir(), [
|
|
28
|
-
now.getFullYear(),
|
|
29
|
-
now.getMonth(),
|
|
30
|
-
now.getDate(),
|
|
31
|
-
'-',
|
|
32
|
-
process.pid,
|
|
33
|
-
'-',
|
|
34
|
-
(Math.random() * 0x100000000 + 1).toString(36),
|
|
35
|
-
].join(''));
|
|
36
|
-
// creates a temp directory using the date and a random string
|
|
37
|
-
await fs_1.fs.mkdir(filePath, { recursive: true });
|
|
38
|
-
return filePath;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* @typedef Affixes
|
|
42
|
-
* @property {string} [prefix] - prefix of the temp directory name
|
|
43
|
-
* @property {string} [suffix] - suffix of the temp directory name
|
|
44
|
-
*/
|
|
45
|
-
/**
|
|
46
|
-
* Generate a temporary directory in os.tempdir() or process.env.APPIUM_TMP_DIR
|
|
47
|
-
* with arbitrary prefix/suffix for the directory name.
|
|
18
|
+
* Generate a temporary directory with arbitrary prefix/suffix for the directory name.
|
|
48
19
|
*
|
|
49
|
-
* @param
|
|
50
|
-
* @param
|
|
51
|
-
* @returns
|
|
20
|
+
* @param rawAffixes - Prefix string, or object with prefix/suffix, or omitted.
|
|
21
|
+
* @param defaultPrefix - Default prefix when rawAffixes is omitted.
|
|
22
|
+
* @returns A path to the temporary directory.
|
|
52
23
|
*/
|
|
53
24
|
async function path(rawAffixes, defaultPrefix) {
|
|
54
25
|
const affixes = parseAffixes(rawAffixes, defaultPrefix);
|
|
55
|
-
const name = `${affixes.prefix
|
|
26
|
+
const name = `${affixes.prefix ?? ''}${affixes.suffix ?? ''}`;
|
|
56
27
|
const tempDirectory = await tempDir();
|
|
57
28
|
return node_path_1.default.join(tempDirectory, name);
|
|
58
29
|
}
|
|
59
30
|
/**
|
|
60
|
-
*
|
|
61
|
-
* @property {string} path - The path to file
|
|
62
|
-
* @property {number} fd - The file descriptor opened
|
|
63
|
-
*/
|
|
64
|
-
/**
|
|
65
|
-
* Generate a temporary directory in os.tempdir() or process.env.APPIUM_TMP_DIR
|
|
66
|
-
* with arbitrary prefix/suffix for the directory name and return it as open.
|
|
31
|
+
* Generate a temp file path with prefix/suffix, open the file, and return path and fd.
|
|
67
32
|
*
|
|
68
|
-
* @param
|
|
69
|
-
* @returns
|
|
33
|
+
* @param affixes - Prefix/suffix for the file name.
|
|
34
|
+
* @returns The opened file path and descriptor.
|
|
70
35
|
*/
|
|
71
36
|
async function open(affixes) {
|
|
72
37
|
const filePath = await path(affixes, 'f-');
|
|
73
38
|
try {
|
|
74
|
-
|
|
75
|
-
// opens the file in mode 384
|
|
39
|
+
const fd = await fs_1.fs.open(filePath, RDWR_EXCL, 0o600);
|
|
76
40
|
return { path: filePath, fd };
|
|
77
41
|
}
|
|
78
42
|
catch (err) {
|
|
79
43
|
throw logger_1.default.errorWithException(err);
|
|
80
44
|
}
|
|
81
45
|
}
|
|
46
|
+
/** Returns a new path to a temporary directory (alias for the tempDir implementation). */
|
|
47
|
+
exports.openDir = tempDir;
|
|
82
48
|
/**
|
|
49
|
+
* Returns a path to a temporary directory which is reused for the life of the process.
|
|
83
50
|
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* @param {string|Affixes} rawAffixes
|
|
87
|
-
* @param {string} [defaultPrefix]
|
|
88
|
-
* @returns {Affixes}
|
|
51
|
+
* @returns The same temp directory path on every call.
|
|
89
52
|
*/
|
|
53
|
+
exports.staticDir = lodash_1.default.memoize(async function staticDir() {
|
|
54
|
+
return tempDir();
|
|
55
|
+
});
|
|
56
|
+
// #region Private
|
|
57
|
+
/**
|
|
58
|
+
* Generate a temporary directory in os.tmpdir() or process.env.APPIUM_TMP_DIR.
|
|
59
|
+
*/
|
|
60
|
+
async function tempDir() {
|
|
61
|
+
const now = new Date();
|
|
62
|
+
const filePath = node_path_1.default.join(process.env.APPIUM_TMP_DIR || node_os_1.default.tmpdir(), [
|
|
63
|
+
now.getFullYear(),
|
|
64
|
+
now.getMonth(),
|
|
65
|
+
now.getDate(),
|
|
66
|
+
'-',
|
|
67
|
+
process.pid,
|
|
68
|
+
'-',
|
|
69
|
+
(Math.random() * 0x100000000 + 1).toString(36),
|
|
70
|
+
].join(''));
|
|
71
|
+
await fs_1.fs.mkdir(filePath, { recursive: true });
|
|
72
|
+
return filePath;
|
|
73
|
+
}
|
|
90
74
|
function parseAffixes(rawAffixes, defaultPrefix) {
|
|
91
|
-
/** @type {Affixes} */
|
|
92
75
|
let affixes = {};
|
|
93
|
-
if (rawAffixes) {
|
|
76
|
+
if (rawAffixes !== undefined && rawAffixes !== null) {
|
|
94
77
|
switch (typeof rawAffixes) {
|
|
95
78
|
case 'string':
|
|
96
|
-
affixes
|
|
79
|
+
affixes = { prefix: rawAffixes };
|
|
97
80
|
break;
|
|
98
81
|
case 'object':
|
|
99
82
|
affixes = rawAffixes;
|
|
100
83
|
break;
|
|
101
84
|
default:
|
|
102
|
-
throw new Error(`Unknown affix declaration: ${
|
|
85
|
+
throw new Error(`Unknown affix declaration: ${String(rawAffixes)}`);
|
|
103
86
|
}
|
|
104
87
|
}
|
|
105
88
|
else {
|
|
@@ -107,20 +90,5 @@ function parseAffixes(rawAffixes, defaultPrefix) {
|
|
|
107
90
|
}
|
|
108
91
|
return affixes;
|
|
109
92
|
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Returns a new path to a temporary directory
|
|
113
|
-
*
|
|
114
|
-
* @returns {string} A new tempDir() if tempRootDirectory is not provided
|
|
115
|
-
*/
|
|
116
|
-
const openDir = tempDir;
|
|
117
|
-
exports.openDir = openDir;
|
|
118
|
-
/**
|
|
119
|
-
* Returns a path to a temporary directory which is defined as static in the same process
|
|
120
|
-
*
|
|
121
|
-
* @returns {Promise<string>} A temp directory path which is defined as static in the same process
|
|
122
|
-
*/
|
|
123
|
-
async function staticDir() {
|
|
124
|
-
return _static;
|
|
125
|
-
}
|
|
93
|
+
// #endregion
|
|
126
94
|
//# sourceMappingURL=tempdir.js.map
|
package/build/lib/tempdir.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tempdir.js","sourceRoot":"","sources":["../../lib/tempdir.
|
|
1
|
+
{"version":3,"file":"tempdir.js","sourceRoot":"","sources":["../../lib/tempdir.ts"],"names":[],"mappings":";;;;;;AA6BA,oBAQC;AAQD,oBAQC;AArDD,kFAAkF;AAClF,6BAAwB;AACxB,sDAAyB;AACzB,0DAAiC;AACjC,oDAAuB;AACvB,qCAAkC;AAClC,sDAA2B;AAE3B,MAAM,SAAS,GAAG,mBAAS,CAAC,OAAO,GAAG,mBAAS,CAAC,OAAO,GAAG,mBAAS,CAAC,MAAM,GAAG,mBAAS,CAAC,MAAM,CAAC;AAc9F;;;;;;GAMG;AACI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,QAAQ,EAAE;QACd,GAAG,CAAC,OAAO,EAAE;QACb,GAAG;QACH,OAAO,CAAC,GAAG;QACX,GAAG;QACH,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,WAAW,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;KAC/C,CAAC,IAAI,CAAC,EAAE,CAAC,CACX,CAAC;IAEF,MAAM,OAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,EAAC,SAAS,EAAE,IAAI,EAAC,CAAC,CAAC;IAE5C,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,SAAS,YAAY,CACnB,UAA6B,EAC7B,aAAsB;IAEtB,IAAI,OAAO,GAAY,EAAE,CAAC;IAC1B,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACpD,QAAQ,OAAO,UAAU,EAAE,CAAC;YAC1B,KAAK,QAAQ;gBACX,OAAO,GAAG,EAAC,MAAM,EAAE,UAAU,EAAC,CAAC;gBAC/B,MAAM;YACR,KAAK,QAAQ;gBACX,OAAO,GAAG,UAAU,CAAC;gBACrB,MAAM;YACR;gBACE,MAAM,IAAI,KAAK,CAAC,8BAA8B,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC;QACxE,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,MAAM,GAAG,aAAa,CAAC;IACjC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,aAAa"}
|
package/build/lib/timing.d.ts
CHANGED
|
@@ -1,28 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
_startTime: bigint | [number, number] | null;
|
|
4
|
-
get startTime(): bigint | [number, number] | null;
|
|
5
|
-
/**
|
|
6
|
-
* Start the timer
|
|
7
|
-
*
|
|
8
|
-
* @return {Timer} The current instance, for chaining
|
|
9
|
-
*/
|
|
10
|
-
start(): Timer;
|
|
11
|
-
/**
|
|
12
|
-
* Get the duration since the timer was started
|
|
13
|
-
*
|
|
14
|
-
* @return {Duration} the duration
|
|
15
|
-
*/
|
|
16
|
-
getDuration(): Duration;
|
|
17
|
-
toString(): string;
|
|
18
|
-
}
|
|
1
|
+
/** High-resolution start time: tuple from process.hrtime() or bigint from process.hrtime.bigint() */
|
|
2
|
+
type HrTime = [number, number] | bigint;
|
|
19
3
|
/**
|
|
20
4
|
* Class representing a duration, encapsulating the number and units.
|
|
21
5
|
*/
|
|
22
|
-
export class Duration {
|
|
23
|
-
|
|
24
|
-
_nanos:
|
|
25
|
-
get nanos():
|
|
6
|
+
export declare class Duration {
|
|
7
|
+
private _nanos;
|
|
8
|
+
constructor(_nanos: number);
|
|
9
|
+
get nanos(): number;
|
|
26
10
|
/**
|
|
27
11
|
* Get the duration as nanoseconds
|
|
28
12
|
*
|
|
@@ -43,4 +27,26 @@ export class Duration {
|
|
|
43
27
|
get asSeconds(): number;
|
|
44
28
|
toString(): string;
|
|
45
29
|
}
|
|
30
|
+
export declare class Timer {
|
|
31
|
+
private _startTime;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a timer
|
|
34
|
+
*/
|
|
35
|
+
constructor(_startTime?: HrTime | null);
|
|
36
|
+
get startTime(): HrTime | null;
|
|
37
|
+
/**
|
|
38
|
+
* Start the timer
|
|
39
|
+
*
|
|
40
|
+
* @return {Timer} The current instance, for chaining
|
|
41
|
+
*/
|
|
42
|
+
start(): this;
|
|
43
|
+
/**
|
|
44
|
+
* Get the duration since the timer was started
|
|
45
|
+
*
|
|
46
|
+
* @return {Duration} the duration
|
|
47
|
+
*/
|
|
48
|
+
getDuration(): Duration;
|
|
49
|
+
toString(): string;
|
|
50
|
+
}
|
|
51
|
+
export { Timer as default };
|
|
46
52
|
//# sourceMappingURL=timing.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timing.d.ts","sourceRoot":"","sources":["../../lib/timing.
|
|
1
|
+
{"version":3,"file":"timing.d.ts","sourceRoot":"","sources":["../../lib/timing.ts"],"names":[],"mappings":"AAKA,qGAAqG;AACrG,KAAK,MAAM,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAAC;AAExC;;GAEG;AACH,qBAAa,QAAQ;IACP,OAAO,CAAC,MAAM;gBAAN,MAAM,EAAE,MAAM;IAElC,IAAI,KAAK,IAAI,MAAM,CAElB;IAED;;;;OAIG;IACH,IAAI,aAAa,IAAI,MAAM,CAE1B;IAED;;;;OAIG;IACH,IAAI,cAAc,IAAI,MAAM,CAE3B;IAED;;;;OAIG;IACH,IAAI,SAAS,IAAI,MAAM,CAEtB;IAED,QAAQ,IAAI,MAAM;CAInB;AAED,qBAAa,KAAK;IAIJ,OAAO,CAAC,UAAU;IAH9B;;OAEG;gBACiB,UAAU,GAAE,MAAM,GAAG,IAAW;IAEpD,IAAI,SAAS,IAAI,MAAM,GAAG,IAAI,CAE7B;IAED;;;;OAIG;IACH,KAAK,IAAI,IAAI;IAQb;;;;OAIG;IACH,WAAW,IAAI,QAAQ;IAsBvB,QAAQ,IAAI,MAAM;CAOnB;AAED,OAAO,EAAC,KAAK,IAAI,OAAO,EAAC,CAAC"}
|