appium 2.0.0-beta.3 → 2.0.0-beta.34
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/README.md +10 -11
- package/build/lib/appium.d.ts +215 -0
- package/build/lib/appium.d.ts.map +1 -0
- package/build/lib/appium.js +241 -132
- package/build/lib/cli/args.d.ts +20 -0
- package/build/lib/cli/args.d.ts.map +1 -0
- package/build/lib/cli/args.js +96 -282
- package/build/lib/cli/driver-command.d.ts +36 -0
- package/build/lib/cli/driver-command.d.ts.map +1 -0
- package/build/lib/cli/driver-command.js +19 -12
- package/build/lib/cli/extension-command.d.ts +345 -0
- package/build/lib/cli/extension-command.d.ts.map +1 -0
- package/build/lib/cli/extension-command.js +171 -96
- package/build/lib/cli/extension.d.ts +14 -0
- package/build/lib/cli/extension.d.ts.map +1 -0
- package/build/lib/cli/extension.js +31 -16
- package/build/lib/cli/parser.d.ts +80 -0
- package/build/lib/cli/parser.d.ts.map +1 -0
- package/build/lib/cli/parser.js +152 -95
- package/build/lib/cli/plugin-command.d.ts +39 -0
- package/build/lib/cli/plugin-command.d.ts.map +1 -0
- package/build/lib/cli/plugin-command.js +18 -13
- package/build/lib/cli/utils.d.ts +29 -0
- package/build/lib/cli/utils.d.ts.map +1 -0
- package/build/lib/cli/utils.js +27 -3
- package/build/lib/config-file.d.ts +100 -0
- package/build/lib/config-file.d.ts.map +1 -0
- package/build/lib/config-file.js +136 -0
- package/build/lib/config.d.ts +41 -0
- package/build/lib/config.d.ts.map +1 -0
- package/build/lib/config.js +92 -67
- package/build/lib/constants.d.ts +48 -0
- package/build/lib/constants.d.ts.map +1 -0
- package/build/lib/constants.js +60 -0
- package/build/lib/extension/driver-config.d.ts +84 -0
- package/build/lib/extension/driver-config.d.ts.map +1 -0
- package/build/lib/extension/driver-config.js +190 -0
- package/build/lib/extension/extension-config.d.ts +170 -0
- package/build/lib/extension/extension-config.d.ts.map +1 -0
- package/build/lib/extension/extension-config.js +297 -0
- package/build/lib/extension/index.d.ts +39 -0
- package/build/lib/extension/index.d.ts.map +1 -0
- package/build/lib/extension/index.js +77 -0
- package/build/lib/extension/manifest.d.ts +174 -0
- package/build/lib/extension/manifest.d.ts.map +1 -0
- package/build/lib/extension/manifest.js +246 -0
- package/build/lib/extension/package-changed.d.ts +11 -0
- package/build/lib/extension/package-changed.d.ts.map +1 -0
- package/build/lib/extension/package-changed.js +68 -0
- package/build/lib/extension/plugin-config.d.ts +62 -0
- package/build/lib/extension/plugin-config.d.ts.map +1 -0
- package/build/lib/extension/plugin-config.js +87 -0
- package/build/lib/grid-register.d.ts +10 -0
- package/build/lib/grid-register.d.ts.map +1 -0
- package/build/lib/grid-register.js +21 -25
- package/build/lib/logger.d.ts +3 -0
- package/build/lib/logger.d.ts.map +1 -0
- package/build/lib/logger.js +4 -6
- package/build/lib/logsink.d.ts +4 -0
- package/build/lib/logsink.d.ts.map +1 -0
- package/build/lib/logsink.js +12 -16
- package/build/lib/main.d.ts +54 -0
- package/build/lib/main.d.ts.map +1 -0
- package/build/lib/main.js +189 -90
- package/build/lib/schema/arg-spec.d.ts +143 -0
- package/build/lib/schema/arg-spec.d.ts.map +1 -0
- package/build/lib/schema/arg-spec.js +119 -0
- package/build/lib/schema/cli-args.d.ts +19 -0
- package/build/lib/schema/cli-args.d.ts.map +1 -0
- package/build/lib/schema/cli-args.js +180 -0
- package/build/lib/schema/cli-transformers.d.ts +5 -0
- package/build/lib/schema/cli-transformers.d.ts.map +1 -0
- package/build/lib/schema/cli-transformers.js +74 -0
- package/build/lib/schema/index.d.ts +3 -0
- package/build/lib/schema/index.d.ts.map +1 -0
- package/build/lib/schema/index.js +34 -0
- package/build/lib/schema/keywords.d.ts +24 -0
- package/build/lib/schema/keywords.d.ts.map +1 -0
- package/build/lib/schema/keywords.js +70 -0
- package/build/lib/schema/schema.d.ts +259 -0
- package/build/lib/schema/schema.d.ts.map +1 -0
- package/build/lib/schema/schema.js +452 -0
- package/build/lib/utils.d.ts +66 -0
- package/build/lib/utils.d.ts.map +1 -0
- package/build/lib/utils.js +35 -139
- package/build/tsconfig.tsbuildinfo +1 -0
- package/build/types/appium-manifest.d.ts +40 -0
- package/build/types/appium-manifest.d.ts.map +1 -0
- package/build/types/cli.d.ts +112 -0
- package/build/types/cli.d.ts.map +1 -0
- package/build/types/extension.d.ts +43 -0
- package/build/types/extension.d.ts.map +1 -0
- package/build/types/external-manifest.d.ts +47 -0
- package/build/types/external-manifest.d.ts.map +1 -0
- package/build/types/index.d.ts +15 -0
- package/build/types/index.d.ts.map +1 -0
- package/index.js +11 -0
- package/lib/appium-config.schema.json +278 -0
- package/lib/appium.js +402 -155
- package/lib/cli/args.js +174 -377
- package/lib/cli/driver-command.js +22 -7
- package/lib/cli/extension-command.js +372 -177
- package/lib/cli/extension.js +32 -10
- package/lib/cli/parser.js +253 -83
- package/lib/cli/plugin-command.js +19 -6
- package/lib/cli/utils.js +22 -2
- package/lib/config-file.js +223 -0
- package/lib/config.js +170 -69
- package/lib/constants.js +78 -0
- package/lib/extension/driver-config.js +249 -0
- package/lib/extension/extension-config.js +458 -0
- package/lib/extension/index.js +102 -0
- package/lib/extension/manifest.js +484 -0
- package/lib/extension/package-changed.js +63 -0
- package/lib/extension/plugin-config.js +113 -0
- package/lib/grid-register.js +25 -22
- package/lib/logger.js +1 -1
- package/lib/logsink.js +14 -7
- package/lib/main.js +255 -90
- package/lib/schema/arg-spec.js +232 -0
- package/lib/schema/cli-args.js +261 -0
- package/lib/schema/cli-transformers.js +122 -0
- package/lib/schema/index.js +2 -0
- package/lib/schema/keywords.js +134 -0
- package/lib/schema/schema.js +734 -0
- package/lib/utils.js +85 -129
- package/package.json +68 -85
- package/scripts/postinstall.js +71 -0
- package/types/appium-manifest.ts +61 -0
- package/types/cli.ts +153 -0
- package/types/extension.ts +56 -0
- package/types/external-manifest.ts +58 -0
- package/types/index.ts +14 -0
- package/CHANGELOG.md +0 -3515
- package/bin/ios-webkit-debug-proxy-launcher.js +0 -71
- package/build/lib/cli/npm.js +0 -206
- package/build/lib/cli/parser-helpers.js +0 -82
- package/build/lib/driver-config.js +0 -77
- package/build/lib/drivers.js +0 -96
- package/build/lib/extension-config.js +0 -251
- package/build/lib/plugin-config.js +0 -59
- package/build/lib/plugins.js +0 -14
- package/lib/cli/npm.js +0 -183
- package/lib/cli/parser-helpers.js +0 -79
- package/lib/driver-config.js +0 -46
- package/lib/drivers.js +0 -81
- package/lib/extension-config.js +0 -208
- package/lib/plugin-config.js +0 -34
- package/lib/plugins.js +0 -10
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
|
|
2
|
+
import _ from 'lodash';
|
|
3
|
+
import {ExtensionConfig} from './extension-config';
|
|
4
|
+
import log from '../logger';
|
|
5
|
+
import {PLUGIN_TYPE} from '../constants';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @extends {ExtensionConfig<PluginType>}
|
|
9
|
+
*/
|
|
10
|
+
export class PluginConfig extends ExtensionConfig {
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* A mapping of {@link Manifest} instances to {@link PluginConfig} instances.
|
|
14
|
+
*
|
|
15
|
+
* `Manifest` and {@link ExtensionConfig} have a one-to-many relationship; each `Manifest` should be associated with a `DriverConfig` and a `PluginConfig`; no more, no less.
|
|
16
|
+
*
|
|
17
|
+
* This variable tracks the `Manifest`-to-`PluginConfig` portion.
|
|
18
|
+
*
|
|
19
|
+
* @type {WeakMap<Manifest,PluginConfig>}
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
static _instances = new WeakMap();
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Call {@link PluginConfig.create} instead.
|
|
26
|
+
*
|
|
27
|
+
* Just calls the superclass' constructor with the correct extension type
|
|
28
|
+
* @private
|
|
29
|
+
* @param {Manifest} manifest - IO object
|
|
30
|
+
* @param {PluginConfigOptions} [opts]
|
|
31
|
+
*/
|
|
32
|
+
constructor (manifest, {extData, logFn} = {}) {
|
|
33
|
+
super(PLUGIN_TYPE, manifest, logFn);
|
|
34
|
+
|
|
35
|
+
if (extData) {
|
|
36
|
+
this.validate(extData);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Creates a new {@link PluginConfig} instance for a {@link Manifest} instance.
|
|
42
|
+
*
|
|
43
|
+
* @param {Manifest} manifest
|
|
44
|
+
* @param {PluginConfigOptions} [opts]
|
|
45
|
+
* @throws If `manifest` already associated with a `PluginConfig`
|
|
46
|
+
* @returns {PluginConfig}
|
|
47
|
+
*/
|
|
48
|
+
static create (manifest, {extData, logFn} = {}) {
|
|
49
|
+
const instance = new PluginConfig(manifest, {logFn, extData});
|
|
50
|
+
if (PluginConfig.getInstance(manifest)) {
|
|
51
|
+
throw new Error(`Manifest with APPIUM_HOME ${manifest.appiumHome} already has a PluginConfig; use PluginConfig.getInstance() to retrieve it.`);
|
|
52
|
+
}
|
|
53
|
+
PluginConfig._instances.set(manifest, instance);
|
|
54
|
+
return instance;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns a PluginConfig associated with a Manifest
|
|
59
|
+
* @param {Manifest} manifest
|
|
60
|
+
* @returns {PluginConfig|undefined}
|
|
61
|
+
*/
|
|
62
|
+
static getInstance (manifest) {
|
|
63
|
+
return PluginConfig._instances.get(manifest);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param {string} pluginName
|
|
68
|
+
* @param {import('../../types/appium-manifest').ExtManifest<PluginType>} pluginData
|
|
69
|
+
* @returns {string}
|
|
70
|
+
*/
|
|
71
|
+
extensionDesc (pluginName, {version}) {
|
|
72
|
+
return `${pluginName}@${version}`;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/**
|
|
76
|
+
*
|
|
77
|
+
* @param {(keyof PluginRecord)[]} activeNames
|
|
78
|
+
* @returns {void}
|
|
79
|
+
*/
|
|
80
|
+
print (activeNames) {
|
|
81
|
+
const pluginNames = Object.keys(this.installedExtensions);
|
|
82
|
+
|
|
83
|
+
if (_.isEmpty(pluginNames)) {
|
|
84
|
+
log.info(`No plugins have been installed. Use the "appium plugin" ` +
|
|
85
|
+
'command to install the one(s) you want to use.');
|
|
86
|
+
return;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
log.info(`Available plugins:`);
|
|
90
|
+
for (const [pluginName, pluginData] of _.toPairs(this.installedExtensions)) {
|
|
91
|
+
const activeTxt = _.includes(activeNames, pluginName) ? ' (ACTIVE)' : '';
|
|
92
|
+
log.info(` - ${this.extensionDesc(pluginName, pluginData)}${activeTxt}`);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (_.isEmpty(activeNames)) {
|
|
96
|
+
log.info('No plugins activated. Use the --use-plugins flag with names of plugins to activate');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* @typedef PluginConfigOptions
|
|
103
|
+
* @property {import('./extension-config').ExtensionLogFn} [logFn] - Optional logging function
|
|
104
|
+
* @property {import('../../types/appium-manifest').PluginRecord} [extData] - Extension data
|
|
105
|
+
*/
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* @typedef {import('../../types/appium-manifest').PluginRecord} PluginRecord
|
|
110
|
+
* @typedef {import('../../types').PluginType} PluginType
|
|
111
|
+
* @typedef {import('../../types/external-manifest').ExtMetadata<PluginType>} PluginMetadata
|
|
112
|
+
* @typedef {import('./manifest').Manifest} Manifest
|
|
113
|
+
*/
|
package/lib/grid-register.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import axios from 'axios';
|
|
2
|
-
import { fs } from 'appium
|
|
2
|
+
import { fs } from '@appium/support';
|
|
3
3
|
import logger from './logger';
|
|
4
4
|
import _ from 'lodash';
|
|
5
5
|
|
|
@@ -9,20 +9,31 @@ const hubUri = (config) => {
|
|
|
9
9
|
return `${protocol}://${config.hubHost}:${config.hubPort}`;
|
|
10
10
|
};
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Registers a new node with a selenium grid
|
|
14
|
+
* @param {string|object} data - Path or object representing selenium grid node config file. If a `string`, all subsequent arguments are required!
|
|
15
|
+
* @param {string} [addr] - Bind to this address
|
|
16
|
+
* @param {number} [port] - Bind to this port
|
|
17
|
+
* @param {string} [basePath] - Base path for the grid
|
|
18
|
+
*/
|
|
19
|
+
async function registerNode (data, addr, port, basePath) {
|
|
20
|
+
let configFilePath;
|
|
21
|
+
if (_.isString(data)) {
|
|
22
|
+
configFilePath = data;
|
|
23
|
+
try {
|
|
24
|
+
data = await fs.readFile(data, 'utf-8');
|
|
25
|
+
} catch (err) {
|
|
26
|
+
logger.error(`Unable to load node configuration file ${configFilePath} to register with grid: ${err.message}`);
|
|
27
|
+
return;
|
|
28
|
+
}
|
|
29
|
+
try {
|
|
30
|
+
data = JSON.parse(data);
|
|
31
|
+
} catch (err) {
|
|
32
|
+
logger.errorAndThrow(`Syntax error in node configuration file ${configFilePath}: ${err.message}`);
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
19
35
|
}
|
|
20
36
|
|
|
21
|
-
// Check presence of data before posting it to the selenium grid
|
|
22
|
-
if (!data) {
|
|
23
|
-
logger.error('No data found in the node configuration file to send to the grid');
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
37
|
postRequest(data, addr, port, basePath);
|
|
27
38
|
}
|
|
28
39
|
|
|
@@ -39,15 +50,7 @@ async function registerToGrid (postOptions, configHolder) {
|
|
|
39
50
|
}
|
|
40
51
|
}
|
|
41
52
|
|
|
42
|
-
function postRequest (
|
|
43
|
-
// parse json to get hub host and port
|
|
44
|
-
let configHolder;
|
|
45
|
-
try {
|
|
46
|
-
configHolder = JSON.parse(data);
|
|
47
|
-
} catch (err) {
|
|
48
|
-
logger.errorAndThrow(`Syntax error in node configuration file: ${err.message}`);
|
|
49
|
-
}
|
|
50
|
-
|
|
53
|
+
function postRequest (configHolder, addr, port, basePath) {
|
|
51
54
|
// Move Selenium 3 configuration properties to configuration object
|
|
52
55
|
if (!_.has(configHolder, 'configuration')) {
|
|
53
56
|
let configuration = {};
|
package/lib/logger.js
CHANGED
package/lib/logsink.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import npmlog from 'npmlog';
|
|
2
2
|
import { createLogger, format, transports } from 'winston';
|
|
3
|
-
import { fs, logger } from 'appium
|
|
4
|
-
import dateformat from 'dateformat';
|
|
3
|
+
import { fs, logger } from '@appium/support';
|
|
5
4
|
import _ from 'lodash';
|
|
6
5
|
|
|
7
6
|
|
|
@@ -36,16 +35,20 @@ const npmToWinstonLevels = {
|
|
|
36
35
|
};
|
|
37
36
|
|
|
38
37
|
let log = null;
|
|
39
|
-
let
|
|
38
|
+
let useLocalTimeZone = false;
|
|
40
39
|
|
|
41
40
|
// add the timestamp in the correct format to the log info object
|
|
42
41
|
const timestampFormat = format.timestamp({
|
|
43
42
|
format () {
|
|
44
43
|
let date = new Date();
|
|
45
|
-
if (
|
|
46
|
-
date = new Date(date.valueOf()
|
|
44
|
+
if (useLocalTimeZone) {
|
|
45
|
+
date = new Date(date.valueOf() - date.getTimezoneOffset() * 60000);
|
|
47
46
|
}
|
|
48
|
-
|
|
47
|
+
// '2012-11-04T14:51:06.157Z' -> '2012-11-04 14:51:06:157'
|
|
48
|
+
return date.toISOString()
|
|
49
|
+
.replace(/[TZ]/g, ' ')
|
|
50
|
+
.replace(/\./g, ':')
|
|
51
|
+
.trim();
|
|
49
52
|
},
|
|
50
53
|
});
|
|
51
54
|
|
|
@@ -63,6 +66,8 @@ const stripColorFormat = format(function stripColor (info) {
|
|
|
63
66
|
|
|
64
67
|
function createConsoleTransport (args, logLvl) {
|
|
65
68
|
return new (transports.Console)({
|
|
69
|
+
// `name` is unsupported per winston's type declarations
|
|
70
|
+
// @ts-expect-error
|
|
66
71
|
name: 'console',
|
|
67
72
|
handleExceptions: true,
|
|
68
73
|
exitOnError: false,
|
|
@@ -89,6 +94,7 @@ function createConsoleTransport (args, logLvl) {
|
|
|
89
94
|
|
|
90
95
|
function createFileTransport (args, logLvl) {
|
|
91
96
|
return new (transports.File)({
|
|
97
|
+
// @ts-expect-error
|
|
92
98
|
name: 'file',
|
|
93
99
|
filename: args.logFile,
|
|
94
100
|
maxFiles: 1,
|
|
@@ -117,6 +123,7 @@ function createHttpTransport (args, logLvl) {
|
|
|
117
123
|
}
|
|
118
124
|
|
|
119
125
|
return new (transports.Http)({
|
|
126
|
+
// @ts-expect-error
|
|
120
127
|
name: 'http',
|
|
121
128
|
host,
|
|
122
129
|
port,
|
|
@@ -182,7 +189,7 @@ async function createTransports (args) {
|
|
|
182
189
|
|
|
183
190
|
async function init (args) {
|
|
184
191
|
// set de facto param passed to timestamp function
|
|
185
|
-
|
|
192
|
+
useLocalTimeZone = args.localTimezone;
|
|
186
193
|
|
|
187
194
|
// clean up in case we have initiated before since npmlog is a global object
|
|
188
195
|
clear();
|