@appium/support 2.61.1 → 3.0.1
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 +1 -1
- package/build/lib/console.js +169 -105
- package/build/lib/console.js.map +1 -1
- package/build/lib/env.d.ts.map +1 -1
- package/build/lib/env.js +144 -117
- package/build/lib/env.js.map +1 -1
- package/build/lib/fs.d.ts +9 -2
- package/build/lib/fs.d.ts.map +1 -1
- package/build/lib/fs.js +358 -246
- package/build/lib/fs.js.map +1 -1
- package/build/lib/image-util.js +139 -124
- package/build/lib/image-util.js.map +1 -1
- package/build/lib/index.js +64 -103
- package/build/lib/index.js.map +1 -1
- package/build/lib/log-internal.d.ts +4 -27
- package/build/lib/log-internal.d.ts.map +1 -1
- package/build/lib/log-internal.js +141 -123
- package/build/lib/log-internal.js.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 +5 -14
- package/build/lib/logger.js.map +1 -1
- package/build/lib/logging.d.ts +3 -4
- package/build/lib/logging.d.ts.map +1 -1
- package/build/lib/logging.js +139 -110
- package/build/lib/logging.js.map +1 -1
- package/build/lib/mjpeg.js +169 -141
- package/build/lib/mjpeg.js.map +1 -1
- package/build/lib/mkdirp.js +7 -13
- package/build/lib/mkdirp.js.map +1 -1
- package/build/lib/net.d.ts.map +1 -1
- package/build/lib/net.js +278 -254
- package/build/lib/net.js.map +1 -1
- package/build/lib/node.js +203 -192
- package/build/lib/node.js.map +1 -1
- package/build/lib/npm.d.ts +19 -4
- package/build/lib/npm.d.ts.map +1 -1
- package/build/lib/npm.js +277 -228
- package/build/lib/npm.js.map +1 -1
- package/build/lib/plist.js +145 -136
- package/build/lib/plist.js.map +1 -1
- package/build/lib/process.js +41 -42
- package/build/lib/process.js.map +1 -1
- package/build/lib/system.js +39 -56
- package/build/lib/system.js.map +1 -1
- package/build/lib/tempdir.js +112 -73
- package/build/lib/tempdir.js.map +1 -1
- package/build/lib/timing.js +99 -84
- package/build/lib/timing.js.map +1 -1
- package/build/lib/util.js +454 -356
- package/build/lib/util.js.map +1 -1
- package/build/lib/zip.js +469 -423
- package/build/lib/zip.js.map +1 -1
- package/build/tsconfig.tsbuildinfo +1 -1
- package/lib/env.js +6 -4
- package/lib/fs.js +15 -1
- package/lib/log-internal.js +12 -16
- package/lib/logging.js +2 -3
- package/lib/net.js +15 -6
- package/lib/npm.js +28 -18
- package/package.json +20 -19
package/lib/log-internal.js
CHANGED
|
@@ -3,6 +3,15 @@ import _ from 'lodash';
|
|
|
3
3
|
|
|
4
4
|
const DEFAULT_REPLACER = '**SECURE**';
|
|
5
5
|
|
|
6
|
+
/**
|
|
7
|
+
* Type guard for log filter type
|
|
8
|
+
* @param {object} value
|
|
9
|
+
* @returns {value is import('@appium/types').LogFilterRegex}
|
|
10
|
+
*/
|
|
11
|
+
function isLogFilterRegex(value) {
|
|
12
|
+
return 'pattern' in value;
|
|
13
|
+
}
|
|
14
|
+
|
|
6
15
|
class SecureValuesPreprocessor {
|
|
7
16
|
constructor() {
|
|
8
17
|
this._rules = [];
|
|
@@ -19,7 +28,7 @@ class SecureValuesPreprocessor {
|
|
|
19
28
|
/**
|
|
20
29
|
* Parses single rule from the given JSON file
|
|
21
30
|
*
|
|
22
|
-
* @param {string|
|
|
31
|
+
* @param {string|import('@appium/types').LogFilter} rule The rule might either be represented as a single string
|
|
23
32
|
* or a configuration object
|
|
24
33
|
* @throws {Error} If there was an error while parsing the rule
|
|
25
34
|
* @returns {SecureValuePreprocessingRule} The parsed rule
|
|
@@ -34,7 +43,7 @@ class SecureValuesPreprocessor {
|
|
|
34
43
|
}
|
|
35
44
|
pattern = `\\b${_.escapeRegExp(rule)}\\b`;
|
|
36
45
|
} else if (_.isPlainObject(rule)) {
|
|
37
|
-
if (
|
|
46
|
+
if (isLogFilterRegex(rule)) {
|
|
38
47
|
if (!_.isString(rule.pattern) || rule.pattern.length === 0) {
|
|
39
48
|
throw new Error(
|
|
40
49
|
`${JSON.stringify(rule)} -> The value of 'pattern' must be a valid non-empty string`
|
|
@@ -81,7 +90,7 @@ class SecureValuesPreprocessor {
|
|
|
81
90
|
/**
|
|
82
91
|
* Loads rules from the given JSON file
|
|
83
92
|
*
|
|
84
|
-
* @param {string|string[]|
|
|
93
|
+
* @param {string|string[]|import('@appium/types').LogFiltersConfig} source The full path to the JSON file containing secure
|
|
85
94
|
* values replacement rules or the rules themselves represented as an array
|
|
86
95
|
* @throws {Error} If the format of the source file is invalid or
|
|
87
96
|
* it does not exist
|
|
@@ -144,19 +153,6 @@ const SECURE_VALUES_PREPROCESSOR = new SecureValuesPreprocessor();
|
|
|
144
153
|
export {SECURE_VALUES_PREPROCESSOR, SecureValuesPreprocessor};
|
|
145
154
|
export default SECURE_VALUES_PREPROCESSOR;
|
|
146
155
|
|
|
147
|
-
/**
|
|
148
|
-
* @typedef Rule
|
|
149
|
-
* @property {string} pattern A valid RegExp pattern to be replaced
|
|
150
|
-
* @property {string} text A text match to replace. Either this property or the
|
|
151
|
-
* above one must be provided. `pattern` has priority over `text` if both are provided.
|
|
152
|
-
* @property {string} [flags] Regular expression flags for the given pattern.
|
|
153
|
-
* Supported flag are the same as for the standard JavaScript RegExp constructor:
|
|
154
|
-
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions#Advanced_searching_with_flags_2
|
|
155
|
-
* The 'g' (global matching) is always enabled though.
|
|
156
|
-
* @property {string} [replacer] The replacer value to use. By default
|
|
157
|
-
* equals to `DEFAULT_SECURE_REPLACER`
|
|
158
|
-
*/
|
|
159
|
-
|
|
160
156
|
/**
|
|
161
157
|
* @typedef SecureValuePreprocessingRule
|
|
162
158
|
* @property {RegExp} pattern The parsed pattern which is going to be used for replacement
|
package/lib/logging.js
CHANGED
|
@@ -137,10 +137,9 @@ function getLogger(prefix = null) {
|
|
|
137
137
|
* appear in Appium logs.
|
|
138
138
|
* Each call to this method replaces the previously loaded rules if any existed.
|
|
139
139
|
*
|
|
140
|
-
* @param {string|string[]|import('
|
|
140
|
+
* @param {string|string[]|import('@appium/types').LogFiltersConfig} rulesJsonPath The full path to the JSON file containing
|
|
141
141
|
* the replacement rules. Each rule could either be a string to be replaced
|
|
142
|
-
* or an object with predefined properties.
|
|
143
|
-
* `log-internals.js` to get more details on its format.
|
|
142
|
+
* or an object with predefined properties.
|
|
144
143
|
* @throws {Error} If the given file cannot be loaded
|
|
145
144
|
* @returns {Promise<LoadResult>}
|
|
146
145
|
*/
|
package/lib/net.js
CHANGED
|
@@ -10,19 +10,28 @@ import FormData from 'form-data';
|
|
|
10
10
|
|
|
11
11
|
const DEFAULT_TIMEOUT_MS = 4 * 60 * 1000;
|
|
12
12
|
|
|
13
|
+
/**
|
|
14
|
+
* Type guard for param to {@linkcode toAxiosAuth}
|
|
15
|
+
* @param {any} value
|
|
16
|
+
* @returns {value is AuthCredentials | import('axios').AxiosBasicCredentials}
|
|
17
|
+
*/
|
|
18
|
+
function isAxiosAuth(value) {
|
|
19
|
+
return _.isPlainObject(value);
|
|
20
|
+
}
|
|
21
|
+
|
|
13
22
|
/**
|
|
14
23
|
* Converts {@linkcode AuthCredentials} to credentials understood by {@linkcode axios}.
|
|
15
24
|
* @param {AuthCredentials | import('axios').AxiosBasicCredentials} [auth]
|
|
16
25
|
* @returns {import('axios').AxiosBasicCredentials?}
|
|
17
26
|
*/
|
|
18
27
|
function toAxiosAuth(auth) {
|
|
19
|
-
if (!
|
|
28
|
+
if (!isAxiosAuth(auth)) {
|
|
20
29
|
return null;
|
|
21
30
|
}
|
|
22
31
|
|
|
23
32
|
const axiosAuth = {
|
|
24
|
-
username:
|
|
25
|
-
password:
|
|
33
|
+
username: 'username' in auth ? auth.username : auth.user,
|
|
34
|
+
password: 'password' in auth ? auth.password : auth.pass,
|
|
26
35
|
};
|
|
27
36
|
return axiosAuth.username && axiosAuth.password ? axiosAuth : null;
|
|
28
37
|
}
|
|
@@ -136,7 +145,7 @@ async function uploadFileToFtp(
|
|
|
136
145
|
*/
|
|
137
146
|
function isHttpUploadOptions(opts, url) {
|
|
138
147
|
try {
|
|
139
|
-
const {protocol} =
|
|
148
|
+
const {protocol} = url;
|
|
140
149
|
return protocol === 'http:' || protocol === 'https:';
|
|
141
150
|
} catch {
|
|
142
151
|
return false;
|
|
@@ -151,7 +160,7 @@ function isHttpUploadOptions(opts, url) {
|
|
|
151
160
|
*/
|
|
152
161
|
function isNotHttpUploadOptions(opts, url) {
|
|
153
162
|
try {
|
|
154
|
-
const {protocol} =
|
|
163
|
+
const {protocol} = url;
|
|
155
164
|
return protocol === 'ftp:';
|
|
156
165
|
} catch {
|
|
157
166
|
return false;
|
|
@@ -243,7 +252,7 @@ async function downloadFile(
|
|
|
243
252
|
try {
|
|
244
253
|
const writer = fs.createWriteStream(dstPath);
|
|
245
254
|
const {data: responseStream, headers: responseHeaders} = await axios(requestOpts);
|
|
246
|
-
responseLength = parseInt(responseHeaders['content-length'], 10);
|
|
255
|
+
responseLength = parseInt(responseHeaders['content-length'] || '0', 10);
|
|
247
256
|
responseStream.pipe(writer);
|
|
248
257
|
|
|
249
258
|
await new B((resolve, reject) => {
|
package/lib/npm.js
CHANGED
|
@@ -41,13 +41,13 @@ export class NPM {
|
|
|
41
41
|
* @param {string} cmd
|
|
42
42
|
* @param {string[]} args
|
|
43
43
|
* @param {ExecOpts} opts
|
|
44
|
-
* @param {Omit<
|
|
44
|
+
* @param {Omit<TeenProcessExecOptions, 'cwd'>} [execOpts]
|
|
45
45
|
*/
|
|
46
46
|
async exec(cmd, args, opts, execOpts = {}) {
|
|
47
47
|
let {cwd, json, lockFile} = opts;
|
|
48
48
|
|
|
49
49
|
// make sure we perform the current operation in cwd
|
|
50
|
-
/** @type {
|
|
50
|
+
/** @type {TeenProcessExecOptions} */
|
|
51
51
|
const teenProcessExecOpts = {...execOpts, cwd};
|
|
52
52
|
|
|
53
53
|
args.unshift(cmd);
|
|
@@ -62,7 +62,7 @@ export class NPM {
|
|
|
62
62
|
runner = async () => await acquireLock(_runner);
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
/** @type {import('teen_process').
|
|
65
|
+
/** @type {import('teen_process').TeenProcessExecResult<string> & {json?: any}} */
|
|
66
66
|
let ret;
|
|
67
67
|
try {
|
|
68
68
|
const {stdout, stderr, code} = await runner();
|
|
@@ -156,14 +156,14 @@ export class NPM {
|
|
|
156
156
|
*/
|
|
157
157
|
getLatestSafeUpgradeFromVersions(curVersion, allVersions) {
|
|
158
158
|
let safeUpgradeVer = null;
|
|
159
|
-
const curSemver = semver.parse(curVersion);
|
|
159
|
+
const curSemver = semver.parse(curVersion) ?? semver.parse(semver.coerce(curVersion));
|
|
160
160
|
if (curSemver === null) {
|
|
161
161
|
throw new Error(`Could not parse current version '${curVersion}'`);
|
|
162
162
|
}
|
|
163
163
|
for (const testVer of allVersions) {
|
|
164
|
-
const testSemver = semver.parse(testVer);
|
|
164
|
+
const testSemver = semver.parse(testVer) ?? semver.parse(semver.coerce(testVer));
|
|
165
165
|
if (testSemver === null) {
|
|
166
|
-
|
|
166
|
+
continue;
|
|
167
167
|
}
|
|
168
168
|
// if the test version is a prerelease, ignore it
|
|
169
169
|
if (testSemver.prerelease.length > 0) {
|
|
@@ -194,9 +194,9 @@ export class NPM {
|
|
|
194
194
|
* @param {string} cwd
|
|
195
195
|
* @param {string} pkgName
|
|
196
196
|
* @param {InstallPackageOpts} [opts]
|
|
197
|
-
* @returns {Promise<
|
|
197
|
+
* @returns {Promise<NpmInstallReceipt>}
|
|
198
198
|
*/
|
|
199
|
-
async installPackage(cwd, pkgName, {pkgVer
|
|
199
|
+
async installPackage(cwd, pkgName, {pkgVer, installType}) {
|
|
200
200
|
/** @type {any} */
|
|
201
201
|
let dummyPkgJson;
|
|
202
202
|
const dummyPkgPath = path.join(cwd, 'package.json');
|
|
@@ -219,15 +219,12 @@ export class NPM {
|
|
|
219
219
|
installOpts.push('--save-exact', '--global-style', '--no-package-lock');
|
|
220
220
|
}
|
|
221
221
|
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
lockFile: this._getInstallLockfilePath(cwd),
|
|
229
|
-
}
|
|
230
|
-
);
|
|
222
|
+
const cmd = installType === 'local' ? 'link' : 'install';
|
|
223
|
+
const res = await this.exec(cmd, [...installOpts, pkgVer ? `${pkgName}@${pkgVer}` : pkgName], {
|
|
224
|
+
cwd,
|
|
225
|
+
json: true,
|
|
226
|
+
lockFile: this._getInstallLockfilePath(cwd),
|
|
227
|
+
});
|
|
231
228
|
|
|
232
229
|
if (res.json) {
|
|
233
230
|
// we parsed a valid json response, so if we got an error here, return that
|
|
@@ -243,7 +240,9 @@ export class NPM {
|
|
|
243
240
|
// (even on Windows!)
|
|
244
241
|
const pkgJsonPath = resolveFrom(cwd, `${pkgName}/package.json`);
|
|
245
242
|
try {
|
|
246
|
-
|
|
243
|
+
const pkgJson = await fs.readFile(pkgJsonPath, 'utf8');
|
|
244
|
+
const pkg = JSON.parse(pkgJson);
|
|
245
|
+
return {installPath: path.dirname(pkgJsonPath), pkg};
|
|
247
246
|
} catch {
|
|
248
247
|
throw new Error(
|
|
249
248
|
'The package was not downloaded correctly; its package.json ' +
|
|
@@ -270,6 +269,7 @@ export const npm = new NPM();
|
|
|
270
269
|
/**
|
|
271
270
|
* Options for {@link NPM.installPackage}
|
|
272
271
|
* @typedef InstallPackageOpts
|
|
272
|
+
* @property {import('type-fest').LiteralUnion<'local', string>} [installType] - whether to install from a local path or from npm
|
|
273
273
|
* @property {string} [pkgVer] - the version of the package to install
|
|
274
274
|
*/
|
|
275
275
|
|
|
@@ -280,3 +280,13 @@ export const npm = new NPM();
|
|
|
280
280
|
* @property {boolean} [json] - If `true`, supply `--json` flag to npm and resolve w/ parsed JSON
|
|
281
281
|
* @property {string} [lockFile] - Path to lockfile to use
|
|
282
282
|
*/
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* @typedef {import('teen_process').TeenProcessExecOptions} TeenProcessExecOptions
|
|
286
|
+
*/
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* @typedef NpmInstallReceipt
|
|
290
|
+
* @property {string} installPath - Path to installed package
|
|
291
|
+
* @property {import('type-fest').PackageJson} pkg - Package data
|
|
292
|
+
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appium/support",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.1",
|
|
4
4
|
"description": "Support libs used across appium packages",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"automation",
|
|
@@ -33,18 +33,13 @@
|
|
|
33
33
|
"build"
|
|
34
34
|
],
|
|
35
35
|
"scripts": {
|
|
36
|
-
"build": "babel lib --root-mode=upward --out-dir=build/lib",
|
|
37
|
-
"dev": "npm run build -- --watch",
|
|
38
|
-
"fix": "npm run lint -- --fix",
|
|
39
|
-
"lint": "eslint -c ../../.eslintrc --ignore-path ../../.eslintignore .",
|
|
40
|
-
"prepare": "npm run build",
|
|
41
36
|
"test": "npm run test:unit",
|
|
42
|
-
"test:e2e": "mocha --timeout 20s --slow 10s \"./test/e2e/**/*.spec.js\"",
|
|
37
|
+
"test:e2e": "mocha -p --timeout 20s --slow 10s \"./test/e2e/**/*.spec.js\"",
|
|
43
38
|
"test:smoke": "node ./index.js",
|
|
44
39
|
"test:unit": "mocha \"./test/unit/**/*.spec.js\""
|
|
45
40
|
},
|
|
46
41
|
"dependencies": {
|
|
47
|
-
"@appium/types": "^0.
|
|
42
|
+
"@appium/types": "^0.7.0",
|
|
48
43
|
"@colors/colors": "1.5.0",
|
|
49
44
|
"@types/archiver": "5.3.1",
|
|
50
45
|
"@types/base64-stream": "1.0.2",
|
|
@@ -59,13 +54,13 @@
|
|
|
59
54
|
"@types/pluralize": "0.0.29",
|
|
60
55
|
"@types/pngjs": "6.0.1",
|
|
61
56
|
"@types/rimraf": "3.0.2",
|
|
62
|
-
"@types/semver": "7.3.
|
|
57
|
+
"@types/semver": "7.3.13",
|
|
63
58
|
"@types/shell-quote": "1.7.1",
|
|
64
59
|
"@types/supports-color": "8.1.1",
|
|
65
|
-
"@types/teen_process": "
|
|
66
|
-
"@types/uuid": "
|
|
60
|
+
"@types/teen_process": "2.0.0",
|
|
61
|
+
"@types/uuid": "9.0.0",
|
|
67
62
|
"archiver": "5.3.1",
|
|
68
|
-
"axios": "
|
|
63
|
+
"axios": "1.2.1",
|
|
69
64
|
"base64-stream": "1.0.0",
|
|
70
65
|
"bluebird": "3.7.2",
|
|
71
66
|
"bplist-creator": "0.1.1",
|
|
@@ -75,14 +70,14 @@
|
|
|
75
70
|
"glob": "8.0.3",
|
|
76
71
|
"jimp": "0.16.2",
|
|
77
72
|
"jsftp": "2.1.3",
|
|
78
|
-
"klaw": "
|
|
73
|
+
"klaw": "4.0.1",
|
|
79
74
|
"lockfile": "1.0.4",
|
|
80
75
|
"lodash": "4.17.21",
|
|
81
76
|
"log-symbols": "4.1.0",
|
|
82
77
|
"moment": "2.29.4",
|
|
83
78
|
"mv": "2.1.1",
|
|
84
79
|
"ncp": "2.0.0",
|
|
85
|
-
"npmlog": "
|
|
80
|
+
"npmlog": "7.0.1",
|
|
86
81
|
"opencv-bindings": "4.5.5",
|
|
87
82
|
"pkg-dir": "5.0.0",
|
|
88
83
|
"plist": "3.0.6",
|
|
@@ -97,17 +92,23 @@
|
|
|
97
92
|
"source-map-support": "0.5.21",
|
|
98
93
|
"supports-color": "8.1.1",
|
|
99
94
|
"teen_process": "2.0.2",
|
|
100
|
-
"type-fest": "3.
|
|
101
|
-
"uuid": "
|
|
102
|
-
"which": "
|
|
95
|
+
"type-fest": "3.4.0",
|
|
96
|
+
"uuid": "9.0.0",
|
|
97
|
+
"which": "3.0.0",
|
|
103
98
|
"yauzl": "2.10.0"
|
|
104
99
|
},
|
|
105
100
|
"engines": {
|
|
106
|
-
"node": ">=
|
|
101
|
+
"node": "^14.17.0 || ^16.13.0 || >=18.0.0",
|
|
107
102
|
"npm": ">=8"
|
|
108
103
|
},
|
|
109
104
|
"publishConfig": {
|
|
110
105
|
"access": "public"
|
|
111
106
|
},
|
|
112
|
-
"gitHead": "
|
|
107
|
+
"gitHead": "2e76ba9607729f59ca967e47c2cba738e90a57b8",
|
|
108
|
+
"typedoc": {
|
|
109
|
+
"entryPoint": "./build/lib/index.js"
|
|
110
|
+
},
|
|
111
|
+
"overrides": {
|
|
112
|
+
"jpeg-js": "0.4.4"
|
|
113
|
+
}
|
|
113
114
|
}
|