@wdio/appium-service 7.20.7 → 7.20.8-alpha.504
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/index.d.ts +3 -3
- package/build/index.d.ts.map +1 -1
- package/build/index.js +4 -25
- package/build/launcher.d.ts.map +1 -1
- package/build/launcher.js +31 -27
- package/build/types.js +1 -2
- package/build/utils.d.ts +1 -1
- package/build/utils.d.ts.map +1 -1
- package/build/utils.js +10 -17
- package/package.json +13 -15
package/build/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import AppiumLauncher from './launcher';
|
|
1
|
+
import AppiumLauncher from './launcher.js';
|
|
2
2
|
export default class AppiumService {
|
|
3
3
|
}
|
|
4
4
|
export declare const launcher: typeof AppiumLauncher;
|
|
5
|
-
export * from './types';
|
|
6
|
-
import { AppiumServiceConfig } from './types';
|
|
5
|
+
export * from './types.js';
|
|
6
|
+
import type { AppiumServiceConfig } from './types';
|
|
7
7
|
declare global {
|
|
8
8
|
namespace WebdriverIO {
|
|
9
9
|
interface ServiceOption extends AppiumServiceConfig {
|
package/build/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,cAAc,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,cAAc,MAAM,eAAe,CAAA;AAE1C,MAAM,CAAC,OAAO,OAAO,aAAa;CAAG;AACrC,eAAO,MAAM,QAAQ,uBAAiB,CAAA;AAEtC,cAAc,YAAY,CAAA;AAC1B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAElD,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,WAAW,CAAC;QAClB,UAAU,aAAc,SAAQ,mBAAmB;SAAG;KACzD;CACJ"}
|
package/build/index.js
CHANGED
|
@@ -1,27 +1,6 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/* istanbul ignore file */
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
7
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
8
|
-
}
|
|
9
|
-
Object.defineProperty(o, k2, desc);
|
|
10
|
-
}) : (function(o, m, k, k2) {
|
|
11
|
-
if (k2 === undefined) k2 = k;
|
|
12
|
-
o[k2] = m[k];
|
|
13
|
-
}));
|
|
14
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
15
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
16
|
-
};
|
|
17
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
18
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
|
-
};
|
|
20
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.launcher = void 0;
|
|
22
|
-
const launcher_1 = __importDefault(require("./launcher"));
|
|
23
|
-
class AppiumService {
|
|
2
|
+
import AppiumLauncher from './launcher.js';
|
|
3
|
+
export default class AppiumService {
|
|
24
4
|
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
__exportStar(require("./types"), exports);
|
|
5
|
+
export const launcher = AppiumLauncher;
|
|
6
|
+
export * from './types.js';
|
package/build/launcher.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"launcher.d.ts","sourceRoot":"","sources":["../src/launcher.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAGlE,OAAO,KAAK,EAAyB,mBAAmB,EAAE,MAAM,SAAS,CAAA;AAYzE,MAAM,CAAC,OAAO,OAAO,cAAe,YAAW,QAAQ,CAAC,eAAe;IAQ/D,OAAO,CAAC,QAAQ;IAChB,OAAO,CAAC,aAAa;IACrB,OAAO,CAAC,OAAO,CAAC;IATpB,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAQ;IAClC,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAe;IAC9C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAuB;IAC7C,OAAO,CAAC,QAAQ,CAAQ;IACxB,OAAO,CAAC,QAAQ,CAAC,CAA+C;gBAGpD,QAAQ,EAAE,mBAAmB,EAC7B,aAAa,EAAE,YAAY,CAAC,kBAAkB,EAC9C,OAAO,CAAC,gCAAoB;IAUxC,OAAO,CAAC,WAAW;IAqBnB;;;OAGG;IACH,OAAO,CAAC,gBAAgB;IA6BlB,SAAS;IAkBf,UAAU;IAOV,OAAO,CAAC,YAAY;YA2BN,kBAAkB;IAehC,OAAO,CAAC,MAAM,CAAC,iBAAiB;CAcnC"}
|
package/build/launcher.js
CHANGED
|
@@ -1,34 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
const utils_1 = require("./utils");
|
|
12
|
-
const log = (0, logger_1.default)('@wdio/appium-service');
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import fsp from 'node:fs/promises';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
import { spawn } from 'node:child_process';
|
|
5
|
+
import { promisify } from 'node:util';
|
|
6
|
+
import { createRequire } from 'node:module';
|
|
7
|
+
import logger from '@wdio/logger';
|
|
8
|
+
import { isCloudCapability } from '@wdio/config';
|
|
9
|
+
import { getFilePath, formatCliArgs } from './utils.js';
|
|
10
|
+
const log = logger('@wdio/appium-service');
|
|
13
11
|
const DEFAULT_LOG_FILENAME = 'wdio-appium.log';
|
|
14
12
|
const DEFAULT_CONNECTION = {
|
|
15
13
|
protocol: 'http',
|
|
16
|
-
hostname: '
|
|
14
|
+
hostname: '127.0.0.1',
|
|
17
15
|
port: 4723,
|
|
18
16
|
path: '/'
|
|
19
17
|
};
|
|
20
|
-
class AppiumLauncher {
|
|
18
|
+
export default class AppiumLauncher {
|
|
19
|
+
_options;
|
|
20
|
+
_capabilities;
|
|
21
|
+
_config;
|
|
22
|
+
_logPath;
|
|
23
|
+
_appiumCliArgs = [];
|
|
24
|
+
_args;
|
|
25
|
+
_command;
|
|
26
|
+
_process;
|
|
21
27
|
constructor(_options, _capabilities, _config) {
|
|
22
|
-
var _a;
|
|
23
28
|
this._options = _options;
|
|
24
29
|
this._capabilities = _capabilities;
|
|
25
30
|
this._config = _config;
|
|
26
|
-
this._appiumCliArgs = [];
|
|
27
31
|
this._args = {
|
|
28
32
|
basePath: DEFAULT_CONNECTION.path,
|
|
29
33
|
...(this._options.args || {})
|
|
30
34
|
};
|
|
31
|
-
this._logPath = _options.logPath ||
|
|
35
|
+
this._logPath = _options.logPath || this._config?.outputDir;
|
|
32
36
|
this._command = this._getCommand(_options.command);
|
|
33
37
|
}
|
|
34
38
|
_getCommand(command) {
|
|
@@ -61,22 +65,22 @@ class AppiumLauncher {
|
|
|
61
65
|
for (const [, capability] of Object.entries(this._capabilities)) {
|
|
62
66
|
const cap = capability.capabilities || capability;
|
|
63
67
|
const c = cap.alwaysMatch || cap;
|
|
64
|
-
!
|
|
68
|
+
!isCloudCapability(c) && Object.assign(capability, DEFAULT_CONNECTION, 'port' in this._args ? { port: this._args.port } : {}, { path: this._args.basePath }, { ...capability });
|
|
65
69
|
}
|
|
66
70
|
return;
|
|
67
71
|
}
|
|
68
|
-
this._capabilities.forEach((cap) => !
|
|
72
|
+
this._capabilities.forEach((cap) => !isCloudCapability(cap.alwaysMatch || cap) && Object.assign(cap, DEFAULT_CONNECTION, 'port' in this._args ? { port: this._args.port } : {}, { path: this._args.basePath }, { ...cap }));
|
|
69
73
|
}
|
|
70
74
|
async onPrepare() {
|
|
71
75
|
/**
|
|
72
76
|
* Append remaining arguments
|
|
73
77
|
*/
|
|
74
|
-
this._appiumCliArgs.push(...
|
|
78
|
+
this._appiumCliArgs.push(...formatCliArgs(this._args));
|
|
75
79
|
this._setCapabilities();
|
|
76
80
|
/**
|
|
77
81
|
* start Appium
|
|
78
82
|
*/
|
|
79
|
-
this._process = await
|
|
83
|
+
this._process = await promisify(this._startAppium)(this._command, this._appiumCliArgs);
|
|
80
84
|
if (this._logPath) {
|
|
81
85
|
this._redirectLogStream(this._logPath);
|
|
82
86
|
}
|
|
@@ -89,7 +93,7 @@ class AppiumLauncher {
|
|
|
89
93
|
}
|
|
90
94
|
_startAppium(command, args, callback) {
|
|
91
95
|
log.debug(`Will spawn Appium process: ${command} ${args.join(' ')}`);
|
|
92
|
-
let process =
|
|
96
|
+
let process = spawn(command, args, { stdio: ['ignore', 'pipe', 'pipe'] });
|
|
93
97
|
let error;
|
|
94
98
|
process.stdout.on('data', (data) => {
|
|
95
99
|
if (data.includes('Appium REST http interface listener started')) {
|
|
@@ -110,20 +114,21 @@ class AppiumLauncher {
|
|
|
110
114
|
callback(new Error(errorMessage), null);
|
|
111
115
|
});
|
|
112
116
|
}
|
|
113
|
-
_redirectLogStream(logPath) {
|
|
117
|
+
async _redirectLogStream(logPath) {
|
|
114
118
|
if (!this._process) {
|
|
115
119
|
throw Error('No Appium process to redirect log stream');
|
|
116
120
|
}
|
|
117
|
-
const logFile =
|
|
121
|
+
const logFile = getFilePath(logPath, DEFAULT_LOG_FILENAME);
|
|
118
122
|
// ensure file & directory exists
|
|
119
|
-
|
|
123
|
+
await fsp.mkdir(path.dirname(logFile), { recursive: true });
|
|
120
124
|
log.debug(`Appium logs written to: ${logFile}`);
|
|
121
|
-
const logStream =
|
|
125
|
+
const logStream = fs.createWriteStream(logFile, { flags: 'w' });
|
|
122
126
|
this._process.stdout.pipe(logStream);
|
|
123
127
|
this._process.stderr.pipe(logStream);
|
|
124
128
|
}
|
|
125
129
|
static _getAppiumCommand(moduleName = 'appium') {
|
|
126
130
|
try {
|
|
131
|
+
const require = createRequire(import.meta.url);
|
|
127
132
|
return require.resolve(moduleName);
|
|
128
133
|
}
|
|
129
134
|
catch (err) {
|
|
@@ -135,4 +140,3 @@ class AppiumLauncher {
|
|
|
135
140
|
}
|
|
136
141
|
}
|
|
137
142
|
}
|
|
138
|
-
exports.default = AppiumLauncher;
|
package/build/types.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/build/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ArgValue, KeyValueArgs } from './types';
|
|
1
|
+
import type { ArgValue, KeyValueArgs } from './types';
|
|
2
2
|
/**
|
|
3
3
|
* Resolves the given path into a absolute path and appends the default filename as fallback when the provided path is a directory.
|
|
4
4
|
* @param {String} filePath relative file or directory path
|
package/build/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAIrD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,GAAG,MAAM,CAU9E;AAED,wBAAgB,aAAa,CAAC,IAAI,EAAE,YAAY,GAAG,QAAQ,EAAE,GAAG,MAAM,EAAE,CAoBvE;AAED,wBAAgB,sBAAsB,CAAE,KAAK,EAAE,QAAQ,UAItD;AAED,wBAAgB,SAAS,IAAI,OAAO,CAEnC"}
|
package/build/utils.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.isWindows = exports.sanitizeCliOptionValue = exports.formatCliArgs = exports.getFilePath = void 0;
|
|
4
|
-
const path_1 = require("path");
|
|
5
|
-
const param_case_1 = require("param-case");
|
|
1
|
+
import { basename, join, resolve } from 'node:path';
|
|
2
|
+
import { paramCase } from 'param-case';
|
|
6
3
|
const FILE_EXTENSION_REGEX = /\.[0-9a-z]+$/i;
|
|
7
4
|
/**
|
|
8
5
|
* Resolves the given path into a absolute path and appends the default filename as fallback when the provided path is a directory.
|
|
@@ -10,17 +7,16 @@ const FILE_EXTENSION_REGEX = /\.[0-9a-z]+$/i;
|
|
|
10
7
|
* @param {String} defaultFilename default file name when filePath is a directory
|
|
11
8
|
* @return {String} absolute file path
|
|
12
9
|
*/
|
|
13
|
-
function getFilePath(filePath, defaultFilename) {
|
|
14
|
-
let absolutePath =
|
|
10
|
+
export function getFilePath(filePath, defaultFilename) {
|
|
11
|
+
let absolutePath = resolve(filePath);
|
|
15
12
|
// test if we already have a file (e.g. selenium.txt, .log, log.txt, etc.)
|
|
16
13
|
// NOTE: path.extname doesn't work to detect a file, cause dotfiles are reported by node to have no extension
|
|
17
|
-
if (!FILE_EXTENSION_REGEX.test(
|
|
18
|
-
absolutePath =
|
|
14
|
+
if (!FILE_EXTENSION_REGEX.test(basename(absolutePath))) {
|
|
15
|
+
absolutePath = join(absolutePath, defaultFilename);
|
|
19
16
|
}
|
|
20
17
|
return absolutePath;
|
|
21
18
|
}
|
|
22
|
-
|
|
23
|
-
function formatCliArgs(args) {
|
|
19
|
+
export function formatCliArgs(args) {
|
|
24
20
|
if (Array.isArray(args)) {
|
|
25
21
|
return args.map(arg => sanitizeCliOptionValue(arg));
|
|
26
22
|
}
|
|
@@ -31,7 +27,7 @@ function formatCliArgs(args) {
|
|
|
31
27
|
if ((typeof value === 'boolean' && !value) || value === null) {
|
|
32
28
|
continue;
|
|
33
29
|
}
|
|
34
|
-
cliArgs.push(`--${
|
|
30
|
+
cliArgs.push(`--${paramCase(key)}`);
|
|
35
31
|
// Only non-boolean and non-null values are added as option values
|
|
36
32
|
if (typeof value !== 'boolean') {
|
|
37
33
|
cliArgs.push(sanitizeCliOptionValue(value));
|
|
@@ -39,14 +35,11 @@ function formatCliArgs(args) {
|
|
|
39
35
|
}
|
|
40
36
|
return cliArgs;
|
|
41
37
|
}
|
|
42
|
-
|
|
43
|
-
function sanitizeCliOptionValue(value) {
|
|
38
|
+
export function sanitizeCliOptionValue(value) {
|
|
44
39
|
const valueString = String(value);
|
|
45
40
|
// Encapsulate the value string in single quotes if it contains a white space
|
|
46
41
|
return /\s/.test(valueString) ? `'${valueString}'` : valueString;
|
|
47
42
|
}
|
|
48
|
-
|
|
49
|
-
function isWindows() {
|
|
43
|
+
export function isWindows() {
|
|
50
44
|
return process.platform === 'win32';
|
|
51
45
|
}
|
|
52
|
-
exports.isWindows = isWindows;
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wdio/appium-service",
|
|
3
|
-
"version": "7.20.
|
|
3
|
+
"version": "7.20.8-alpha.504+428a9d729",
|
|
4
4
|
"description": "A WebdriverIO service to start & stop Appium Server",
|
|
5
5
|
"author": "Morten Bjerg Gregersen <morten@mogee.dk>",
|
|
6
6
|
"homepage": "https://github.com/webdriverio/webdriverio/tree/main/packages/wdio-appium-service",
|
|
7
7
|
"license": "MIT",
|
|
8
|
-
"main": "./build/index",
|
|
9
8
|
"engines": {
|
|
10
|
-
"node": ">=
|
|
9
|
+
"node": "^16.13 || >=18"
|
|
11
10
|
},
|
|
12
11
|
"repository": {
|
|
13
12
|
"type": "git",
|
|
14
|
-
"url": "git://github.com/webdriverio/webdriverio.git"
|
|
13
|
+
"url": "git://github.com/webdriverio/webdriverio.git",
|
|
14
|
+
"directory": "packages/wdio-appium-service"
|
|
15
15
|
},
|
|
16
16
|
"keywords": [
|
|
17
17
|
"webdriver",
|
|
@@ -25,20 +25,18 @@
|
|
|
25
25
|
"bugs": {
|
|
26
26
|
"url": "https://github.com/webdriverio/webdriverio/issues"
|
|
27
27
|
},
|
|
28
|
+
"type": "module",
|
|
29
|
+
"exports": "./build/index.js",
|
|
30
|
+
"types": "./build/index.d.ts",
|
|
31
|
+
"typeScriptVersion": "3.8.3",
|
|
28
32
|
"dependencies": {
|
|
29
|
-
"@
|
|
30
|
-
"@wdio/
|
|
31
|
-
"@wdio/
|
|
32
|
-
"
|
|
33
|
-
"fs-extra": "^10.0.0",
|
|
34
|
-
"param-case": "^3.0.0"
|
|
35
|
-
},
|
|
36
|
-
"peerDependencies": {
|
|
37
|
-
"@wdio/cli": "^7.0.0"
|
|
33
|
+
"@wdio/config": "7.20.8-alpha.504+428a9d729",
|
|
34
|
+
"@wdio/logger": "7.20.8-alpha.504+428a9d729",
|
|
35
|
+
"@wdio/types": "7.20.8-alpha.504+428a9d729",
|
|
36
|
+
"param-case": "^3.0.4"
|
|
38
37
|
},
|
|
39
38
|
"publishConfig": {
|
|
40
39
|
"access": "public"
|
|
41
40
|
},
|
|
42
|
-
"
|
|
43
|
-
"gitHead": "21b8b61453f4749d87eca3e4d7d6e5e2cb60f043"
|
|
41
|
+
"gitHead": "428a9d729ae6231968a60908732fa3f607d195e9"
|
|
44
42
|
}
|