@appium/support 2.58.0 → 2.59.2
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/build/lib/console.d.ts +110 -0
- package/build/lib/console.d.ts.map +1 -0
- package/build/lib/console.js +113 -0
- package/build/lib/env.d.ts.map +1 -1
- package/build/lib/env.js +1 -1
- package/build/lib/fs.d.ts.map +1 -1
- package/build/lib/fs.js +1 -1
- package/build/lib/image-util.d.ts.map +1 -1
- package/build/lib/image-util.js +1 -1
- package/build/lib/index.d.ts +3 -1
- package/build/lib/index.js +8 -3
- package/build/lib/log-internal.d.ts.map +1 -1
- package/build/lib/log-internal.js +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/logging.d.ts +11 -4
- package/build/lib/logging.d.ts.map +1 -1
- package/build/lib/logging.js +7 -6
- package/build/lib/mjpeg.d.ts.map +1 -1
- package/build/lib/mjpeg.js +1 -1
- package/build/lib/mkdirp.js +1 -1
- package/build/lib/net.d.ts +5 -2
- package/build/lib/net.d.ts.map +1 -1
- package/build/lib/net.js +1 -1
- package/build/lib/node.d.ts.map +1 -1
- package/build/lib/node.js +1 -1
- package/build/lib/npm.d.ts.map +1 -1
- package/build/lib/npm.js +1 -1
- package/build/lib/plist.d.ts +1 -1
- package/build/lib/plist.d.ts.map +1 -1
- package/build/lib/plist.js +1 -1
- package/build/lib/process.d.ts.map +1 -1
- package/build/lib/process.js +1 -1
- package/build/lib/system.js +1 -1
- package/build/lib/tempdir.d.ts.map +1 -1
- package/build/lib/tempdir.js +1 -1
- package/build/lib/timing.d.ts.map +1 -1
- package/build/lib/timing.js +1 -1
- package/build/lib/util.d.ts +19 -2
- package/build/lib/util.d.ts.map +1 -1
- package/build/lib/util.js +3 -7
- package/build/lib/zip.d.ts +5 -5
- package/build/lib/zip.d.ts.map +1 -1
- package/build/lib/zip.js +2 -2
- package/build/tsconfig.tsbuildinfo +1 -1
- package/lib/console.js +173 -0
- package/lib/env.js +12 -14
- package/lib/fs.js +87 -62
- package/lib/image-util.js +50 -32
- package/lib/index.js +39 -8
- package/lib/log-internal.js +16 -11
- package/lib/logger.js +1 -1
- package/lib/logging.js +32 -30
- package/lib/mjpeg.js +32 -27
- package/lib/mkdirp.js +3 -3
- package/lib/net.js +60 -52
- package/lib/node.js +22 -17
- package/lib/npm.js +50 -47
- package/lib/plist.js +34 -18
- package/lib/process.js +8 -6
- package/lib/system.js +8 -8
- package/lib/tempdir.js +14 -9
- package/lib/timing.js +12 -15
- package/lib/util.js +121 -72
- package/lib/zip.js +88 -92
- package/package.json +12 -8
package/lib/plist.js
CHANGED
|
@@ -5,18 +5,17 @@ import fs from './fs';
|
|
|
5
5
|
import log from './logger';
|
|
6
6
|
import _ from 'lodash';
|
|
7
7
|
|
|
8
|
-
|
|
9
8
|
const BPLIST_IDENTIFIER = {
|
|
10
9
|
BUFFER: Buffer.from('bplist00'),
|
|
11
|
-
TEXT: 'bplist00'
|
|
10
|
+
TEXT: 'bplist00',
|
|
12
11
|
};
|
|
13
12
|
const PLIST_IDENTIFIER = {
|
|
14
13
|
BUFFER: Buffer.from('<'),
|
|
15
|
-
TEXT: '<'
|
|
14
|
+
TEXT: '<',
|
|
16
15
|
};
|
|
17
16
|
|
|
18
17
|
// XML Plist library helper
|
|
19
|
-
async function parseXmlPlistFile
|
|
18
|
+
async function parseXmlPlistFile(plistFilename) {
|
|
20
19
|
let xmlContent = await fs.readFile(plistFilename, 'utf8');
|
|
21
20
|
return xmlplist.parse(xmlContent);
|
|
22
21
|
}
|
|
@@ -28,9 +27,9 @@ async function parseXmlPlistFile (plistFilename) {
|
|
|
28
27
|
* @param {boolean} quiet If set to false, the plist path will be logged in debug level
|
|
29
28
|
* @returns {Promise<any>} parsed plist JS Object
|
|
30
29
|
*/
|
|
31
|
-
async function parsePlistFile
|
|
30
|
+
async function parsePlistFile(plist, mustExist = true, quiet = true) {
|
|
32
31
|
// handle nonexistant file
|
|
33
|
-
if (!await fs.exists(plist)) {
|
|
32
|
+
if (!(await fs.exists(plist))) {
|
|
34
33
|
if (mustExist) {
|
|
35
34
|
log.errorAndThrow(`Plist file doesn't exist: '${plist}'`);
|
|
36
35
|
} else {
|
|
@@ -71,7 +70,13 @@ async function parsePlistFile (plist, mustExist = true, quiet = true) {
|
|
|
71
70
|
* @param {boolean} mustExist If set to false, this method will update an empty plist
|
|
72
71
|
* @param {boolean} quiet If set to false, the plist path will be logged in debug level
|
|
73
72
|
*/
|
|
74
|
-
async function updatePlistFile
|
|
73
|
+
async function updatePlistFile(
|
|
74
|
+
plist,
|
|
75
|
+
updatedFields,
|
|
76
|
+
binary = true,
|
|
77
|
+
mustExist = true,
|
|
78
|
+
quiet = true
|
|
79
|
+
) {
|
|
75
80
|
let obj;
|
|
76
81
|
try {
|
|
77
82
|
obj = await parsePlistFile(plist, mustExist);
|
|
@@ -94,7 +99,7 @@ async function updatePlistFile (plist, updatedFields, binary = true, mustExist =
|
|
|
94
99
|
* @param {Object} data The object to be turned into a binary plist
|
|
95
100
|
* @returns {Buffer} plist in the form of a binary buffer
|
|
96
101
|
*/
|
|
97
|
-
function createBinaryPlist
|
|
102
|
+
function createBinaryPlist(data) {
|
|
98
103
|
return bplistCreate(data);
|
|
99
104
|
}
|
|
100
105
|
|
|
@@ -102,28 +107,32 @@ function createBinaryPlist (data) {
|
|
|
102
107
|
* Parses a Buffer into an Object
|
|
103
108
|
* @param {Buffer} data The beffer of a binary plist
|
|
104
109
|
*/
|
|
105
|
-
function parseBinaryPlist
|
|
106
|
-
// this function exists, but is not in the type declarations.
|
|
107
|
-
// @ts-expect-error
|
|
110
|
+
function parseBinaryPlist(data) {
|
|
108
111
|
return bplistParse.parseBuffer(data);
|
|
109
112
|
}
|
|
110
113
|
|
|
111
|
-
function getXmlPlist
|
|
114
|
+
function getXmlPlist(data) {
|
|
112
115
|
if (_.isString(data) && data.startsWith(PLIST_IDENTIFIER.TEXT)) {
|
|
113
116
|
return data;
|
|
114
117
|
}
|
|
115
|
-
if (
|
|
118
|
+
if (
|
|
119
|
+
_.isBuffer(data) &&
|
|
120
|
+
PLIST_IDENTIFIER.BUFFER.compare(data, 0, PLIST_IDENTIFIER.BUFFER.length) === 0
|
|
121
|
+
) {
|
|
116
122
|
return data.toString();
|
|
117
123
|
}
|
|
118
124
|
return null;
|
|
119
125
|
}
|
|
120
126
|
|
|
121
|
-
function getBinaryPlist
|
|
127
|
+
function getBinaryPlist(data) {
|
|
122
128
|
if (_.isString(data) && data.startsWith(BPLIST_IDENTIFIER.TEXT)) {
|
|
123
129
|
return Buffer.from(data);
|
|
124
130
|
}
|
|
125
131
|
|
|
126
|
-
if (
|
|
132
|
+
if (
|
|
133
|
+
_.isBuffer(data) &&
|
|
134
|
+
BPLIST_IDENTIFIER.BUFFER.compare(data, 0, BPLIST_IDENTIFIER.BUFFER.length) === 0
|
|
135
|
+
) {
|
|
127
136
|
return data;
|
|
128
137
|
}
|
|
129
138
|
return null;
|
|
@@ -135,7 +144,7 @@ function getBinaryPlist (data) {
|
|
|
135
144
|
* @param {boolean} binary Set it to true for a binary plist
|
|
136
145
|
* @returns {string|Buffer} returns a buffer or a string in respect to the binary parameter
|
|
137
146
|
*/
|
|
138
|
-
function createPlist
|
|
147
|
+
function createPlist(object, binary = false) {
|
|
139
148
|
if (binary) {
|
|
140
149
|
return createBinaryPlist(object);
|
|
141
150
|
} else {
|
|
@@ -149,7 +158,7 @@ function createPlist (object, binary = false) {
|
|
|
149
158
|
* @returns {Object} parsed plist JS Object
|
|
150
159
|
* @throws Will throw an error if the plist type is unknown
|
|
151
160
|
*/
|
|
152
|
-
function parsePlist
|
|
161
|
+
function parsePlist(data) {
|
|
153
162
|
let textPlist = getXmlPlist(data);
|
|
154
163
|
if (textPlist) {
|
|
155
164
|
return xmlplist.parse(textPlist);
|
|
@@ -163,4 +172,11 @@ function parsePlist (data) {
|
|
|
163
172
|
throw new Error(`Unknown type of plist, data: ${data.toString()}`);
|
|
164
173
|
}
|
|
165
174
|
|
|
166
|
-
export {
|
|
175
|
+
export {
|
|
176
|
+
parsePlistFile,
|
|
177
|
+
parsePlist,
|
|
178
|
+
createPlist,
|
|
179
|
+
updatePlistFile,
|
|
180
|
+
createBinaryPlist,
|
|
181
|
+
parseBinaryPlist,
|
|
182
|
+
};
|
package/lib/process.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import {exec} from 'teen_process';
|
|
3
2
|
|
|
4
3
|
/*
|
|
5
4
|
* Exit Status for pgrep and pkill (`man pkill`)
|
|
@@ -9,11 +8,14 @@ import { exec } from 'teen_process';
|
|
|
9
8
|
* 3. Fatal error: out of memory etc.
|
|
10
9
|
*/
|
|
11
10
|
|
|
12
|
-
async function getProcessIds
|
|
11
|
+
async function getProcessIds(appName) {
|
|
13
12
|
let pids;
|
|
14
13
|
try {
|
|
15
14
|
let {stdout} = await exec('pgrep', ['-x', appName]);
|
|
16
|
-
pids = stdout
|
|
15
|
+
pids = stdout
|
|
16
|
+
.trim()
|
|
17
|
+
.split('\n')
|
|
18
|
+
.map((pid) => parseInt(pid, 10));
|
|
17
19
|
} catch (err) {
|
|
18
20
|
if (parseInt(err.code, 10) !== 1) {
|
|
19
21
|
throw new Error(`Error getting process ids for app '${appName}': ${err.message}`);
|
|
@@ -23,7 +25,7 @@ async function getProcessIds (appName) {
|
|
|
23
25
|
return pids;
|
|
24
26
|
}
|
|
25
27
|
|
|
26
|
-
async function killProcess
|
|
28
|
+
async function killProcess(appName, force = false) {
|
|
27
29
|
let pids = await getProcessIds(appName);
|
|
28
30
|
if (pids.length === 0) {
|
|
29
31
|
// the process is not running
|
|
@@ -41,4 +43,4 @@ async function killProcess (appName, force = false) {
|
|
|
41
43
|
}
|
|
42
44
|
}
|
|
43
45
|
|
|
44
|
-
export {
|
|
46
|
+
export {getProcessIds, killProcess};
|
package/lib/system.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {exec} from 'teen_process';
|
|
2
2
|
import _ from 'lodash';
|
|
3
3
|
import os from 'os';
|
|
4
4
|
|
|
5
5
|
const VERSION_PATTERN = /^(\d+\.\d+)/m;
|
|
6
6
|
|
|
7
|
-
function isWindows
|
|
7
|
+
function isWindows() {
|
|
8
8
|
return os.type() === 'Windows_NT';
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
function isMac
|
|
11
|
+
function isMac() {
|
|
12
12
|
return os.type() === 'Darwin';
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
function isLinux
|
|
15
|
+
function isLinux() {
|
|
16
16
|
return !isWindows() && !isMac();
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
function isOSWin64
|
|
19
|
+
function isOSWin64() {
|
|
20
20
|
return process.arch === 'x64' || _.has(process.env, 'PROCESSOR_ARCHITEW6432');
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
-
async function arch
|
|
23
|
+
async function arch() {
|
|
24
24
|
if (isLinux() || isMac()) {
|
|
25
25
|
let {stdout} = await exec('uname', ['-m']);
|
|
26
26
|
return stdout.trim() === 'i686' ? '32' : '64';
|
|
@@ -30,7 +30,7 @@ async function arch () {
|
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
async function macOsxVersion
|
|
33
|
+
async function macOsxVersion() {
|
|
34
34
|
let stdout;
|
|
35
35
|
try {
|
|
36
36
|
stdout = (await exec('sw_vers', ['-productVersion'])).stdout.trim();
|
|
@@ -45,4 +45,4 @@ async function macOsxVersion () {
|
|
|
45
45
|
return versionMatch[1];
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
export {
|
|
48
|
+
export {isWindows, isMac, isLinux, isOSWin64, arch, macOsxVersion};
|
package/lib/tempdir.js
CHANGED
|
@@ -15,16 +15,20 @@ const RDWR_EXCL = cnst.O_CREAT | cnst.O_TRUNC | cnst.O_RDWR | cnst.O_EXCL;
|
|
|
15
15
|
*
|
|
16
16
|
* @returns {Promise<string>} A path to the temporary directory
|
|
17
17
|
*/
|
|
18
|
-
async function tempDir
|
|
18
|
+
async function tempDir() {
|
|
19
19
|
const now = new Date();
|
|
20
|
-
const filePath = nodePath.join(
|
|
20
|
+
const filePath = nodePath.join(
|
|
21
|
+
process.env.APPIUM_TMP_DIR || os.tmpdir(),
|
|
21
22
|
[
|
|
22
|
-
now.getFullYear(),
|
|
23
|
+
now.getFullYear(),
|
|
24
|
+
now.getMonth(),
|
|
25
|
+
now.getDate(),
|
|
23
26
|
'-',
|
|
24
27
|
process.pid,
|
|
25
28
|
'-',
|
|
26
29
|
(Math.random() * 0x100000000 + 1).toString(36),
|
|
27
|
-
].join('')
|
|
30
|
+
].join('')
|
|
31
|
+
);
|
|
28
32
|
// creates a temp directory using the date and a random string
|
|
29
33
|
|
|
30
34
|
await fs.mkdir(filePath);
|
|
@@ -46,7 +50,7 @@ async function tempDir () {
|
|
|
46
50
|
* @param {string} [defaultPrefix]
|
|
47
51
|
* @returns {Promise<string>} A path to the temporary directory with rawAffixes and defaultPrefix
|
|
48
52
|
*/
|
|
49
|
-
async function path
|
|
53
|
+
async function path(rawAffixes, defaultPrefix) {
|
|
50
54
|
const affixes = parseAffixes(rawAffixes, defaultPrefix);
|
|
51
55
|
const name = `${affixes.prefix || ''}${affixes.suffix || ''}`;
|
|
52
56
|
const tempDirectory = await tempDir();
|
|
@@ -66,7 +70,7 @@ async function path (rawAffixes, defaultPrefix) {
|
|
|
66
70
|
* @param {Affixes} affixes
|
|
67
71
|
* @returns {Promise<OpenedAffixes>}
|
|
68
72
|
*/
|
|
69
|
-
async function open
|
|
73
|
+
async function open(affixes) {
|
|
70
74
|
const filePath = await path(affixes, 'f-');
|
|
71
75
|
try {
|
|
72
76
|
let fd = await fs.open(filePath, RDWR_EXCL, 0o600);
|
|
@@ -85,7 +89,7 @@ async function open (affixes) {
|
|
|
85
89
|
* @param {string} [defaultPrefix]
|
|
86
90
|
* @returns {Affixes}
|
|
87
91
|
*/
|
|
88
|
-
function parseAffixes
|
|
92
|
+
function parseAffixes(rawAffixes, defaultPrefix) {
|
|
89
93
|
/** @type {Affixes} */
|
|
90
94
|
let affixes = {};
|
|
91
95
|
if (rawAffixes) {
|
|
@@ -119,8 +123,9 @@ const openDir = tempDir;
|
|
|
119
123
|
*
|
|
120
124
|
* @returns {Promise<string>} A temp directory path whcih is defined as static in the same process
|
|
121
125
|
*/
|
|
122
|
-
|
|
126
|
+
// eslint-disable-next-line require-await
|
|
127
|
+
async function staticDir() {
|
|
123
128
|
return _static;
|
|
124
129
|
}
|
|
125
130
|
|
|
126
|
-
export {
|
|
131
|
+
export {open, path, openDir, staticDir};
|
package/lib/timing.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
1
|
import _ from 'lodash';
|
|
2
2
|
|
|
3
|
-
|
|
4
3
|
const NS_PER_S = 1e9;
|
|
5
4
|
const NS_PER_MS = 1e6;
|
|
6
5
|
|
|
7
|
-
|
|
8
6
|
/**
|
|
9
7
|
* Class representing a duration, encapsulating the number and units.
|
|
10
8
|
*/
|
|
11
9
|
class Duration {
|
|
12
|
-
constructor
|
|
10
|
+
constructor(nanos) {
|
|
13
11
|
this._nanos = nanos;
|
|
14
12
|
}
|
|
15
13
|
|
|
16
|
-
get nanos
|
|
14
|
+
get nanos() {
|
|
17
15
|
return this._nanos;
|
|
18
16
|
}
|
|
19
17
|
|
|
@@ -22,7 +20,7 @@ class Duration {
|
|
|
22
20
|
*
|
|
23
21
|
* @returns {number} The duration as nanoseconds
|
|
24
22
|
*/
|
|
25
|
-
get asNanoSeconds
|
|
23
|
+
get asNanoSeconds() {
|
|
26
24
|
return this.nanos;
|
|
27
25
|
}
|
|
28
26
|
|
|
@@ -31,7 +29,7 @@ class Duration {
|
|
|
31
29
|
*
|
|
32
30
|
* @returns {number} The duration as milliseconds
|
|
33
31
|
*/
|
|
34
|
-
get asMilliSeconds
|
|
32
|
+
get asMilliSeconds() {
|
|
35
33
|
return this.nanos / NS_PER_MS;
|
|
36
34
|
}
|
|
37
35
|
|
|
@@ -40,11 +38,11 @@ class Duration {
|
|
|
40
38
|
*
|
|
41
39
|
* @returns {number} The duration fas seconds
|
|
42
40
|
*/
|
|
43
|
-
get asSeconds
|
|
41
|
+
get asSeconds() {
|
|
44
42
|
return this.nanos / NS_PER_S;
|
|
45
43
|
}
|
|
46
44
|
|
|
47
|
-
toString
|
|
45
|
+
toString() {
|
|
48
46
|
// default to milliseconds, rounded
|
|
49
47
|
return this.asMilliSeconds.toFixed(0);
|
|
50
48
|
}
|
|
@@ -54,11 +52,11 @@ class Timer {
|
|
|
54
52
|
/**
|
|
55
53
|
* Creates a timer
|
|
56
54
|
*/
|
|
57
|
-
constructor
|
|
55
|
+
constructor() {
|
|
58
56
|
this._startTime = null;
|
|
59
57
|
}
|
|
60
58
|
|
|
61
|
-
get startTime
|
|
59
|
+
get startTime() {
|
|
62
60
|
return this._startTime;
|
|
63
61
|
}
|
|
64
62
|
|
|
@@ -67,7 +65,7 @@ class Timer {
|
|
|
67
65
|
*
|
|
68
66
|
* @return {Timer} The current instance, for chaining
|
|
69
67
|
*/
|
|
70
|
-
start
|
|
68
|
+
start() {
|
|
71
69
|
if (!_.isNull(this.startTime)) {
|
|
72
70
|
throw new Error('Timer has already been started.');
|
|
73
71
|
}
|
|
@@ -83,7 +81,7 @@ class Timer {
|
|
|
83
81
|
*
|
|
84
82
|
* @return {Duration} the duration
|
|
85
83
|
*/
|
|
86
|
-
getDuration
|
|
84
|
+
getDuration() {
|
|
87
85
|
if (_.isNull(this.startTime)) {
|
|
88
86
|
throw new Error(`Unable to get duration. Timer was not started`);
|
|
89
87
|
}
|
|
@@ -105,7 +103,7 @@ class Timer {
|
|
|
105
103
|
return new Duration(nanoDuration);
|
|
106
104
|
}
|
|
107
105
|
|
|
108
|
-
toString
|
|
106
|
+
toString() {
|
|
109
107
|
try {
|
|
110
108
|
return this.getDuration().toString();
|
|
111
109
|
} catch (err) {
|
|
@@ -114,6 +112,5 @@ class Timer {
|
|
|
114
112
|
}
|
|
115
113
|
}
|
|
116
114
|
|
|
117
|
-
|
|
118
|
-
export { Timer, Duration };
|
|
115
|
+
export {Timer, Duration};
|
|
119
116
|
export default Timer;
|