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.
Files changed (149) hide show
  1. package/README.md +10 -11
  2. package/build/lib/appium.d.ts +215 -0
  3. package/build/lib/appium.d.ts.map +1 -0
  4. package/build/lib/appium.js +241 -132
  5. package/build/lib/cli/args.d.ts +20 -0
  6. package/build/lib/cli/args.d.ts.map +1 -0
  7. package/build/lib/cli/args.js +96 -282
  8. package/build/lib/cli/driver-command.d.ts +36 -0
  9. package/build/lib/cli/driver-command.d.ts.map +1 -0
  10. package/build/lib/cli/driver-command.js +19 -12
  11. package/build/lib/cli/extension-command.d.ts +345 -0
  12. package/build/lib/cli/extension-command.d.ts.map +1 -0
  13. package/build/lib/cli/extension-command.js +171 -96
  14. package/build/lib/cli/extension.d.ts +14 -0
  15. package/build/lib/cli/extension.d.ts.map +1 -0
  16. package/build/lib/cli/extension.js +31 -16
  17. package/build/lib/cli/parser.d.ts +80 -0
  18. package/build/lib/cli/parser.d.ts.map +1 -0
  19. package/build/lib/cli/parser.js +152 -95
  20. package/build/lib/cli/plugin-command.d.ts +39 -0
  21. package/build/lib/cli/plugin-command.d.ts.map +1 -0
  22. package/build/lib/cli/plugin-command.js +18 -13
  23. package/build/lib/cli/utils.d.ts +29 -0
  24. package/build/lib/cli/utils.d.ts.map +1 -0
  25. package/build/lib/cli/utils.js +27 -3
  26. package/build/lib/config-file.d.ts +100 -0
  27. package/build/lib/config-file.d.ts.map +1 -0
  28. package/build/lib/config-file.js +136 -0
  29. package/build/lib/config.d.ts +41 -0
  30. package/build/lib/config.d.ts.map +1 -0
  31. package/build/lib/config.js +92 -67
  32. package/build/lib/constants.d.ts +48 -0
  33. package/build/lib/constants.d.ts.map +1 -0
  34. package/build/lib/constants.js +60 -0
  35. package/build/lib/extension/driver-config.d.ts +84 -0
  36. package/build/lib/extension/driver-config.d.ts.map +1 -0
  37. package/build/lib/extension/driver-config.js +190 -0
  38. package/build/lib/extension/extension-config.d.ts +170 -0
  39. package/build/lib/extension/extension-config.d.ts.map +1 -0
  40. package/build/lib/extension/extension-config.js +297 -0
  41. package/build/lib/extension/index.d.ts +39 -0
  42. package/build/lib/extension/index.d.ts.map +1 -0
  43. package/build/lib/extension/index.js +77 -0
  44. package/build/lib/extension/manifest.d.ts +174 -0
  45. package/build/lib/extension/manifest.d.ts.map +1 -0
  46. package/build/lib/extension/manifest.js +246 -0
  47. package/build/lib/extension/package-changed.d.ts +11 -0
  48. package/build/lib/extension/package-changed.d.ts.map +1 -0
  49. package/build/lib/extension/package-changed.js +68 -0
  50. package/build/lib/extension/plugin-config.d.ts +62 -0
  51. package/build/lib/extension/plugin-config.d.ts.map +1 -0
  52. package/build/lib/extension/plugin-config.js +87 -0
  53. package/build/lib/grid-register.d.ts +10 -0
  54. package/build/lib/grid-register.d.ts.map +1 -0
  55. package/build/lib/grid-register.js +21 -25
  56. package/build/lib/logger.d.ts +3 -0
  57. package/build/lib/logger.d.ts.map +1 -0
  58. package/build/lib/logger.js +4 -6
  59. package/build/lib/logsink.d.ts +4 -0
  60. package/build/lib/logsink.d.ts.map +1 -0
  61. package/build/lib/logsink.js +12 -16
  62. package/build/lib/main.d.ts +54 -0
  63. package/build/lib/main.d.ts.map +1 -0
  64. package/build/lib/main.js +189 -90
  65. package/build/lib/schema/arg-spec.d.ts +143 -0
  66. package/build/lib/schema/arg-spec.d.ts.map +1 -0
  67. package/build/lib/schema/arg-spec.js +119 -0
  68. package/build/lib/schema/cli-args.d.ts +19 -0
  69. package/build/lib/schema/cli-args.d.ts.map +1 -0
  70. package/build/lib/schema/cli-args.js +180 -0
  71. package/build/lib/schema/cli-transformers.d.ts +5 -0
  72. package/build/lib/schema/cli-transformers.d.ts.map +1 -0
  73. package/build/lib/schema/cli-transformers.js +74 -0
  74. package/build/lib/schema/index.d.ts +3 -0
  75. package/build/lib/schema/index.d.ts.map +1 -0
  76. package/build/lib/schema/index.js +34 -0
  77. package/build/lib/schema/keywords.d.ts +24 -0
  78. package/build/lib/schema/keywords.d.ts.map +1 -0
  79. package/build/lib/schema/keywords.js +70 -0
  80. package/build/lib/schema/schema.d.ts +259 -0
  81. package/build/lib/schema/schema.d.ts.map +1 -0
  82. package/build/lib/schema/schema.js +452 -0
  83. package/build/lib/utils.d.ts +66 -0
  84. package/build/lib/utils.d.ts.map +1 -0
  85. package/build/lib/utils.js +35 -139
  86. package/build/tsconfig.tsbuildinfo +1 -0
  87. package/build/types/appium-manifest.d.ts +40 -0
  88. package/build/types/appium-manifest.d.ts.map +1 -0
  89. package/build/types/cli.d.ts +112 -0
  90. package/build/types/cli.d.ts.map +1 -0
  91. package/build/types/extension.d.ts +43 -0
  92. package/build/types/extension.d.ts.map +1 -0
  93. package/build/types/external-manifest.d.ts +47 -0
  94. package/build/types/external-manifest.d.ts.map +1 -0
  95. package/build/types/index.d.ts +15 -0
  96. package/build/types/index.d.ts.map +1 -0
  97. package/index.js +11 -0
  98. package/lib/appium-config.schema.json +278 -0
  99. package/lib/appium.js +402 -155
  100. package/lib/cli/args.js +174 -377
  101. package/lib/cli/driver-command.js +22 -7
  102. package/lib/cli/extension-command.js +372 -177
  103. package/lib/cli/extension.js +32 -10
  104. package/lib/cli/parser.js +253 -83
  105. package/lib/cli/plugin-command.js +19 -6
  106. package/lib/cli/utils.js +22 -2
  107. package/lib/config-file.js +223 -0
  108. package/lib/config.js +170 -69
  109. package/lib/constants.js +78 -0
  110. package/lib/extension/driver-config.js +249 -0
  111. package/lib/extension/extension-config.js +458 -0
  112. package/lib/extension/index.js +102 -0
  113. package/lib/extension/manifest.js +484 -0
  114. package/lib/extension/package-changed.js +63 -0
  115. package/lib/extension/plugin-config.js +113 -0
  116. package/lib/grid-register.js +25 -22
  117. package/lib/logger.js +1 -1
  118. package/lib/logsink.js +14 -7
  119. package/lib/main.js +255 -90
  120. package/lib/schema/arg-spec.js +232 -0
  121. package/lib/schema/cli-args.js +261 -0
  122. package/lib/schema/cli-transformers.js +122 -0
  123. package/lib/schema/index.js +2 -0
  124. package/lib/schema/keywords.js +134 -0
  125. package/lib/schema/schema.js +734 -0
  126. package/lib/utils.js +85 -129
  127. package/package.json +68 -85
  128. package/scripts/postinstall.js +71 -0
  129. package/types/appium-manifest.ts +61 -0
  130. package/types/cli.ts +153 -0
  131. package/types/extension.ts +56 -0
  132. package/types/external-manifest.ts +58 -0
  133. package/types/index.ts +14 -0
  134. package/CHANGELOG.md +0 -3515
  135. package/bin/ios-webkit-debug-proxy-launcher.js +0 -71
  136. package/build/lib/cli/npm.js +0 -206
  137. package/build/lib/cli/parser-helpers.js +0 -82
  138. package/build/lib/driver-config.js +0 -77
  139. package/build/lib/drivers.js +0 -96
  140. package/build/lib/extension-config.js +0 -251
  141. package/build/lib/plugin-config.js +0 -59
  142. package/build/lib/plugins.js +0 -14
  143. package/lib/cli/npm.js +0 -183
  144. package/lib/cli/parser-helpers.js +0 -79
  145. package/lib/driver-config.js +0 -46
  146. package/lib/drivers.js +0 -81
  147. package/lib/extension-config.js +0 -208
  148. package/lib/plugin-config.js +0 -34
  149. 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
+ */
@@ -1,5 +1,5 @@
1
1
  import axios from 'axios';
2
- import { fs } from 'appium-support';
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
- async function registerNode (configFile, addr, port, basePath) {
13
- let data;
14
- try {
15
- data = await fs.readFile(configFile, 'utf-8');
16
- } catch (err) {
17
- logger.error(`Unable to load node configuration file to register with grid: ${err.message}`);
18
- return;
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 (data, addr, port, basePath) {
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
@@ -1,4 +1,4 @@
1
- import { logger } from 'appium-support';
1
+ import { logger } from '@appium/support';
2
2
 
3
3
 
4
4
  let log = logger.getLogger('Appium');
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-support';
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 timeZone = null;
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 (!timeZone) {
46
- date = new Date(date.valueOf() + date.getTimezoneOffset() * 60000);
44
+ if (useLocalTimeZone) {
45
+ date = new Date(date.valueOf() - date.getTimezoneOffset() * 60000);
47
46
  }
48
- return dateformat(date, 'yyyy-mm-dd HH:MM:ss:l');
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
- timeZone = args.localTimezone;
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();