appium 2.0.0-beta.7 → 2.0.0-beta.70

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 (206) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +149 -58
  3. package/build/lib/appium.d.ts +229 -0
  4. package/build/lib/appium.d.ts.map +1 -0
  5. package/build/lib/appium.js +678 -439
  6. package/build/lib/appium.js.map +1 -0
  7. package/build/lib/cli/args.d.ts +17 -0
  8. package/build/lib/cli/args.d.ts.map +1 -0
  9. package/build/lib/cli/args.js +263 -300
  10. package/build/lib/cli/args.js.map +1 -0
  11. package/build/lib/cli/driver-command.d.ts +102 -0
  12. package/build/lib/cli/driver-command.d.ts.map +1 -0
  13. package/build/lib/cli/driver-command.js +131 -81
  14. package/build/lib/cli/driver-command.js.map +1 -0
  15. package/build/lib/cli/extension-command.d.ts +402 -0
  16. package/build/lib/cli/extension-command.d.ts.map +1 -0
  17. package/build/lib/cli/extension-command.js +799 -383
  18. package/build/lib/cli/extension-command.js.map +1 -0
  19. package/build/lib/cli/extension.d.ts +23 -0
  20. package/build/lib/cli/extension.d.ts.map +1 -0
  21. package/build/lib/cli/extension.js +71 -60
  22. package/build/lib/cli/extension.js.map +1 -0
  23. package/build/lib/cli/parser.d.ts +84 -0
  24. package/build/lib/cli/parser.d.ts.map +1 -0
  25. package/build/lib/cli/parser.js +252 -148
  26. package/build/lib/cli/parser.js.map +1 -0
  27. package/build/lib/cli/plugin-command.d.ts +99 -0
  28. package/build/lib/cli/plugin-command.d.ts.map +1 -0
  29. package/build/lib/cli/plugin-command.js +125 -81
  30. package/build/lib/cli/plugin-command.js.map +1 -0
  31. package/build/lib/cli/utils.d.ts +29 -0
  32. package/build/lib/cli/utils.d.ts.map +1 -0
  33. package/build/lib/cli/utils.js +72 -51
  34. package/build/lib/cli/utils.js.map +1 -0
  35. package/build/lib/config-file.d.ts +100 -0
  36. package/build/lib/config-file.d.ts.map +1 -0
  37. package/build/lib/config-file.js +207 -0
  38. package/build/lib/config-file.js.map +1 -0
  39. package/build/lib/config.d.ts +49 -0
  40. package/build/lib/config.d.ts.map +1 -0
  41. package/build/lib/config.js +262 -223
  42. package/build/lib/config.js.map +1 -0
  43. package/build/lib/constants.d.ts +56 -0
  44. package/build/lib/constants.d.ts.map +1 -0
  45. package/build/lib/constants.js +73 -0
  46. package/build/lib/constants.js.map +1 -0
  47. package/build/lib/extension/driver-config.d.ts +82 -0
  48. package/build/lib/extension/driver-config.d.ts.map +1 -0
  49. package/build/lib/extension/driver-config.js +210 -0
  50. package/build/lib/extension/driver-config.js.map +1 -0
  51. package/build/lib/extension/extension-config.d.ts +270 -0
  52. package/build/lib/extension/extension-config.d.ts.map +1 -0
  53. package/build/lib/extension/extension-config.js +601 -0
  54. package/build/lib/extension/extension-config.js.map +1 -0
  55. package/build/lib/extension/index.d.ts +48 -0
  56. package/build/lib/extension/index.d.ts.map +1 -0
  57. package/build/lib/extension/index.js +105 -0
  58. package/build/lib/extension/index.js.map +1 -0
  59. package/build/lib/extension/manifest-migrations.d.ts +27 -0
  60. package/build/lib/extension/manifest-migrations.d.ts.map +1 -0
  61. package/build/lib/extension/manifest-migrations.js +134 -0
  62. package/build/lib/extension/manifest-migrations.js.map +1 -0
  63. package/build/lib/extension/manifest.d.ts +145 -0
  64. package/build/lib/extension/manifest.d.ts.map +1 -0
  65. package/build/lib/extension/manifest.js +528 -0
  66. package/build/lib/extension/manifest.js.map +1 -0
  67. package/build/lib/extension/package-changed.d.ts +11 -0
  68. package/build/lib/extension/package-changed.d.ts.map +1 -0
  69. package/build/lib/extension/package-changed.js +62 -0
  70. package/build/lib/extension/package-changed.js.map +1 -0
  71. package/build/lib/extension/plugin-config.d.ts +56 -0
  72. package/build/lib/extension/plugin-config.d.ts.map +1 -0
  73. package/build/lib/extension/plugin-config.js +102 -0
  74. package/build/lib/extension/plugin-config.js.map +1 -0
  75. package/build/lib/grid-register.d.ts +10 -0
  76. package/build/lib/grid-register.d.ts.map +1 -0
  77. package/build/lib/grid-register.js +122 -144
  78. package/build/lib/grid-register.js.map +1 -0
  79. package/build/lib/logger.d.ts +3 -0
  80. package/build/lib/logger.d.ts.map +1 -0
  81. package/build/lib/logger.js +5 -17
  82. package/build/lib/logger.js.map +1 -0
  83. package/build/lib/logsink.d.ts +4 -0
  84. package/build/lib/logsink.d.ts.map +1 -0
  85. package/build/lib/logsink.js +189 -184
  86. package/build/lib/logsink.js.map +1 -0
  87. package/build/lib/main.d.ts +62 -0
  88. package/build/lib/main.d.ts.map +1 -0
  89. package/build/lib/main.js +388 -234
  90. package/build/lib/main.js.map +1 -0
  91. package/build/lib/schema/arg-spec.d.ts +143 -0
  92. package/build/lib/schema/arg-spec.d.ts.map +1 -0
  93. package/build/lib/schema/arg-spec.js +164 -0
  94. package/build/lib/schema/arg-spec.js.map +1 -0
  95. package/build/lib/schema/cli-args.d.ts +19 -0
  96. package/build/lib/schema/cli-args.d.ts.map +1 -0
  97. package/build/lib/schema/cli-args.js +220 -0
  98. package/build/lib/schema/cli-args.js.map +1 -0
  99. package/build/lib/schema/cli-transformers.d.ts +5 -0
  100. package/build/lib/schema/cli-transformers.d.ts.map +1 -0
  101. package/build/lib/schema/cli-transformers.js +124 -0
  102. package/build/lib/schema/cli-transformers.js.map +1 -0
  103. package/build/lib/schema/index.d.ts +3 -0
  104. package/build/lib/schema/index.d.ts.map +1 -0
  105. package/build/lib/schema/index.js +19 -0
  106. package/build/lib/schema/index.js.map +1 -0
  107. package/build/lib/schema/keywords.d.ts +24 -0
  108. package/build/lib/schema/keywords.d.ts.map +1 -0
  109. package/build/lib/schema/keywords.js +128 -0
  110. package/build/lib/schema/keywords.js.map +1 -0
  111. package/build/lib/schema/schema.d.ts +260 -0
  112. package/build/lib/schema/schema.d.ts.map +1 -0
  113. package/build/lib/schema/schema.js +640 -0
  114. package/build/lib/schema/schema.js.map +1 -0
  115. package/build/lib/utils.d.ts +266 -0
  116. package/build/lib/utils.d.ts.map +1 -0
  117. package/build/lib/utils.js +349 -273
  118. package/build/lib/utils.js.map +1 -0
  119. package/build/types/cli.d.ts +134 -0
  120. package/build/types/cli.d.ts.map +1 -0
  121. package/build/types/cli.js +3 -0
  122. package/build/types/cli.js.map +1 -0
  123. package/build/types/index.d.ts +15 -0
  124. package/build/types/index.d.ts.map +1 -0
  125. package/build/types/index.js +19 -0
  126. package/build/types/index.js.map +1 -0
  127. package/build/types/manifest/base.d.ts +135 -0
  128. package/build/types/manifest/base.d.ts.map +1 -0
  129. package/build/types/manifest/base.js +3 -0
  130. package/build/types/manifest/base.js.map +1 -0
  131. package/build/types/manifest/index.d.ts +21 -0
  132. package/build/types/manifest/index.d.ts.map +1 -0
  133. package/build/types/manifest/index.js +42 -0
  134. package/build/types/manifest/index.js.map +1 -0
  135. package/build/types/manifest/v3.d.ts +139 -0
  136. package/build/types/manifest/v3.d.ts.map +1 -0
  137. package/build/types/manifest/v3.js +3 -0
  138. package/build/types/manifest/v3.js.map +1 -0
  139. package/build/types/manifest/v4.d.ts +139 -0
  140. package/build/types/manifest/v4.d.ts.map +1 -0
  141. package/build/types/manifest/v4.js +3 -0
  142. package/build/types/manifest/v4.js.map +1 -0
  143. package/driver.d.ts +1 -0
  144. package/driver.js +14 -0
  145. package/index.js +11 -0
  146. package/lib/appium.js +558 -186
  147. package/lib/cli/args.js +275 -407
  148. package/lib/cli/driver-command.js +132 -24
  149. package/lib/cli/extension-command.js +751 -272
  150. package/lib/cli/extension.js +47 -20
  151. package/lib/cli/parser.js +267 -95
  152. package/lib/cli/plugin-command.js +122 -22
  153. package/lib/cli/utils.js +24 -10
  154. package/lib/config-file.js +220 -0
  155. package/lib/config.js +243 -132
  156. package/lib/constants.js +79 -0
  157. package/lib/extension/driver-config.js +247 -0
  158. package/lib/extension/extension-config.js +709 -0
  159. package/lib/extension/index.js +116 -0
  160. package/lib/extension/manifest-migrations.js +136 -0
  161. package/lib/extension/manifest.js +580 -0
  162. package/lib/extension/package-changed.js +64 -0
  163. package/lib/extension/plugin-config.js +112 -0
  164. package/lib/grid-register.js +49 -35
  165. package/lib/logger.js +1 -2
  166. package/lib/logsink.js +59 -36
  167. package/lib/main.js +369 -104
  168. package/lib/schema/arg-spec.js +229 -0
  169. package/lib/schema/cli-args.js +241 -0
  170. package/lib/schema/cli-transformers.js +119 -0
  171. package/lib/schema/index.js +2 -0
  172. package/lib/schema/keywords.js +136 -0
  173. package/lib/schema/schema.js +725 -0
  174. package/lib/utils.js +289 -167
  175. package/package.json +84 -83
  176. package/plugin.d.ts +1 -0
  177. package/plugin.js +13 -0
  178. package/scripts/autoinstall-extensions.js +243 -0
  179. package/support.d.ts +1 -0
  180. package/support.js +13 -0
  181. package/tsconfig.json +25 -0
  182. package/types/cli.ts +193 -0
  183. package/types/index.ts +20 -0
  184. package/types/manifest/README.md +30 -0
  185. package/types/manifest/base.ts +158 -0
  186. package/types/manifest/index.ts +28 -0
  187. package/types/manifest/v3.ts +161 -0
  188. package/types/manifest/v4.ts +161 -0
  189. package/CHANGELOG.md +0 -3594
  190. package/bin/ios-webkit-debug-proxy-launcher.js +0 -71
  191. package/build/lib/cli/argparse-actions.js +0 -104
  192. package/build/lib/cli/npm.js +0 -200
  193. package/build/lib/cli/parser-helpers.js +0 -93
  194. package/build/lib/driver-config.js +0 -77
  195. package/build/lib/drivers.js +0 -99
  196. package/build/lib/extension-config.js +0 -253
  197. package/build/lib/plugin-config.js +0 -59
  198. package/build/lib/plugins.js +0 -14
  199. package/lib/cli/argparse-actions.js +0 -77
  200. package/lib/cli/npm.js +0 -175
  201. package/lib/cli/parser-helpers.js +0 -91
  202. package/lib/driver-config.js +0 -46
  203. package/lib/drivers.js +0 -84
  204. package/lib/extension-config.js +0 -209
  205. package/lib/plugin-config.js +0 -34
  206. package/lib/plugins.js +0 -10
@@ -0,0 +1,105 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getActiveDrivers = exports.getActivePlugins = exports.loadExtensions = void 0;
7
+ const lodash_1 = __importDefault(require("lodash"));
8
+ const constants_1 = require("../constants");
9
+ const logger_1 = __importDefault(require("../logger"));
10
+ const driver_config_1 = require("./driver-config");
11
+ const manifest_1 = require("./manifest");
12
+ const plugin_config_1 = require("./plugin-config");
13
+ const bluebird_1 = __importDefault(require("bluebird"));
14
+ /**
15
+ * Loads extensions and creates `ExtensionConfig` instances.
16
+ *
17
+ * - Reads the manifest file, creating if necessary
18
+ * - Using the parsed extension data, creates/gets the `ExtensionConfig` subclass instances
19
+ * - Returns these instances
20
+ *
21
+ * If `appiumHome` is needed, use `resolveAppiumHome` from the `env` module in `@appium/support`.
22
+ * @param {string} appiumHome
23
+ * @returns {Promise<ExtensionConfigs>}
24
+ */
25
+ async function loadExtensions(appiumHome) {
26
+ const manifest = manifest_1.Manifest.getInstance(appiumHome);
27
+ await manifest.read();
28
+ const driverConfig = driver_config_1.DriverConfig.getInstance(manifest) ?? driver_config_1.DriverConfig.create(manifest);
29
+ const pluginConfig = plugin_config_1.PluginConfig.getInstance(manifest) ?? plugin_config_1.PluginConfig.create(manifest);
30
+ await bluebird_1.default.all([driverConfig.validate(), pluginConfig.validate()]);
31
+ return { driverConfig, pluginConfig };
32
+ }
33
+ exports.loadExtensions = loadExtensions;
34
+ /**
35
+ * Find any plugin name which has been installed, and which has been requested for activation by
36
+ * using the --use-plugins flag, and turn each one into its class, so we can send them as objects
37
+ * to the server init. We also want to send/assign them to the umbrella driver so it can use them
38
+ * to wrap command execution
39
+ *
40
+ * @param {import('./plugin-config').PluginConfig} pluginConfig - a plugin extension config
41
+ * @param {string[]} usePlugins
42
+ * @returns {PluginNameMap} Mapping of PluginClass to name
43
+ */
44
+ function getActivePlugins(pluginConfig, usePlugins = []) {
45
+ return new Map(lodash_1.default.compact(Object.keys(pluginConfig.installedExtensions)
46
+ .filter((pluginName) => lodash_1.default.includes(usePlugins, pluginName) ||
47
+ (usePlugins.length === 1 && usePlugins[0] === constants_1.USE_ALL_PLUGINS))
48
+ .map((pluginName) => {
49
+ try {
50
+ logger_1.default.info(`Attempting to load plugin ${pluginName}...`);
51
+ const PluginClass = pluginConfig.require(pluginName);
52
+ return [PluginClass, pluginName];
53
+ }
54
+ catch (err) {
55
+ logger_1.default.error(`Could not load plugin '${pluginName}', so it will not be available. Error ` +
56
+ `in loading the plugin was: ${err.message}`);
57
+ logger_1.default.debug(err.stack);
58
+ }
59
+ })));
60
+ }
61
+ exports.getActivePlugins = getActivePlugins;
62
+ /**
63
+ * Find any driver name which has been installed, and turn each one into its class, so we can send
64
+ * them as objects to the server init in case they need to add methods/routes or update the server.
65
+ * If the --drivers flag was given, this method only loads the given drivers.
66
+ *
67
+ * @param {import('./driver-config').DriverConfig} driverConfig - a driver extension config
68
+ * @param {string[]} [useDrivers] - optional list of drivers to load
69
+ * @returns {DriverNameMap}
70
+ */
71
+ function getActiveDrivers(driverConfig, useDrivers = []) {
72
+ return new Map(lodash_1.default.compact(Object.keys(driverConfig.installedExtensions)
73
+ .filter((driverName) => lodash_1.default.includes(useDrivers, driverName) || useDrivers.length === 0)
74
+ .map((driverName) => {
75
+ try {
76
+ logger_1.default.info(`Attempting to load driver ${driverName}...`);
77
+ const DriverClass = driverConfig.require(driverName);
78
+ return [DriverClass, driverName];
79
+ }
80
+ catch (err) {
81
+ logger_1.default.error(`Could not load driver '${driverName}', so it will not be available. Error ` +
82
+ `in loading the driver was: ${err.message}`);
83
+ logger_1.default.debug(err.stack);
84
+ }
85
+ })));
86
+ }
87
+ exports.getActiveDrivers = getActiveDrivers;
88
+ /**
89
+ * A mapping of {@linkcode PluginClass} classes to their names.
90
+ * @typedef {Map<PluginClass,string>} PluginNameMap
91
+ */
92
+ /**
93
+ * A mapping of {@linkcode DriverClass} classes to their names.
94
+ * @typedef {Map<DriverClass,string>} DriverNameMap
95
+ */
96
+ /**
97
+ * @typedef {import('@appium/types').PluginClass} PluginClass
98
+ * @typedef {import('@appium/types').DriverClass} DriverClass
99
+ */
100
+ /**
101
+ * @typedef ExtensionConfigs
102
+ * @property {import('./driver-config').DriverConfig} driverConfig
103
+ * @property {import('./plugin-config').PluginConfig} pluginConfig
104
+ */
105
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../lib/extension/index.js"],"names":[],"mappings":";;;;;;AAAA,oDAAuB;AACvB,4CAA6C;AAC7C,uDAA4B;AAC5B,mDAA6C;AAC7C,yCAAoC;AACpC,mDAA6C;AAC7C,wDAAyB;AAEzB;;;;;;;;;;GAUG;AACI,KAAK,UAAU,cAAc,CAAC,UAAU;IAC7C,MAAM,QAAQ,GAAG,mBAAQ,CAAC,WAAW,CAAC,UAAU,CAAC,CAAC;IAClD,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;IACtB,MAAM,YAAY,GAAG,4BAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,4BAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACzF,MAAM,YAAY,GAAG,4BAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,IAAI,4BAAY,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEzF,MAAM,kBAAC,CAAC,GAAG,CAAC,CAAC,YAAY,CAAC,QAAQ,EAAE,EAAE,YAAY,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAChE,OAAO,EAAC,YAAY,EAAE,YAAY,EAAC,CAAC;AACtC,CAAC;AARD,wCAQC;AAED;;;;;;;;;GASG;AACH,SAAgB,gBAAgB,CAAC,YAAY,EAAE,UAAU,GAAG,EAAE;IAC5D,OAAO,IAAI,GAAG,CACZ,gBAAC,CAAC,OAAO,CACP,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,mBAAmB,CAAC;SAC1C,MAAM,CACL,CAAC,UAAU,EAAE,EAAE,CACb,gBAAC,CAAC,QAAQ,CAAC,UAAU,EAAE,U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CAAwC;gBAC1E,8BAA8B,GAAG,CAAC,OAAO,EAAE,CAC9C,CAAC;YACF,gBAAG,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SACtB;IACH,CAAC,CAAC,CACL,CACF,CAAC;AACJ,CAAC;AApBD,4CAoBC;AAED;;;GAGG;AAEH;;;GAGG;AAEH;;;GAGG;AAEH;;;;GAIG"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Applies a series of migration functions to a manifest to update its manifest schema version.
3
+ *
4
+ * `data` is modified in-place.
5
+ *
6
+ * @param {Readonly<Manifest>} manifest
7
+ * @returns {Promise<boolean>} If `true` existing packages should be synced from disk and the manifest should be persisted.
8
+ */
9
+ export function migrate(manifest: Readonly<Manifest>): Promise<boolean>;
10
+ /**
11
+ * A migration function. It will return `true` if a change _should be made_.
12
+ *
13
+ * A migration function should not modify `schemaRev`, as this is done automatically.
14
+ *
15
+ * Note that at the time of writing, we're not able to determine the version of the _current_ manifest file if there is no `schemaRev` prop present (and we may not want to trust it anyway).
16
+ */
17
+ export type Migration = (manifest: Readonly<Manifest>) => boolean | Promise<boolean>;
18
+ export type ManifestData = import('appium/types').ManifestData;
19
+ export type DriverType = import('@appium/types').DriverType;
20
+ export type PluginType = import('@appium/types').PluginType;
21
+ export type AnyManifestDataVersion = import('appium/types').AnyManifestDataVersion;
22
+ export type ManifestDataVersions = import('appium/types').ManifestDataVersions;
23
+ export type ExtensionType = import('@appium/types').ExtensionType;
24
+ export type ManifestDataV2 = import('appium/types').ManifestV2.ManifestData;
25
+ export type Manifest = import('./manifest').Manifest;
26
+ export type ExtManifest<ExtType extends import("@appium/types").ExtensionType> = import('appium/types').ExtManifest<ExtType>;
27
+ //# sourceMappingURL=manifest-migrations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-migrations.d.ts","sourceRoot":"","sources":["../../../lib/extension/manifest-migrations.js"],"names":[],"mappings":"AAwFA;;;;;;;GAOG;AACH,kCAHW,SAAS,QAAQ,CAAC,GAChB,QAAQ,OAAO,CAAC,CAc5B;;;;;;;;mCASU,SAAS,QAAQ,CAAC,KAChB,OAAO,GAAC,QAAQ,OAAO,CAAC;2BAIxB,OAAO,cAAc,EAAE,YAAY;yBACnC,OAAO,eAAe,EAAE,UAAU;yBAClC,OAAO,eAAe,EAAE,UAAU;qCAClC,OAAO,cAAc,EAAE,sBAAsB;mCAC7C,OAAO,cAAc,EAAE,oBAAoB;4BAC3C,OAAO,eAAe,EAAE,aAAa;6BACrC,OAAO,cAAc,EAAE,UAAU,CAAC,YAAY;uBAC9C,OAAO,YAAY,EAAE,QAAQ;iFAK7B,OAAO,cAAc,EAAE,WAAW,CAAC,OAAO,CAAC"}
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.migrate = void 0;
7
+ const constants_1 = require("../constants");
8
+ const logger_1 = __importDefault(require("../logger"));
9
+ /**
10
+ * This contains logic to migrate old versions of `extensions.yaml` to new versions.
11
+ *
12
+ * @module
13
+ */
14
+ /**
15
+ * Constant for v3 of the schema rev.
16
+ */
17
+ const SCHEMA_REV_3 = 3;
18
+ /**
19
+ * Constant for v4 of the schema rev.
20
+ */
21
+ const SCHEMA_REV_4 = 4;
22
+ /**
23
+ * Collection of functions to migrate from one version to another.
24
+ *
25
+ * These functions _should not actually perform the migration_; rather, they
26
+ * should return `true` if the migration should be performed. The migration
27
+ * itself will happen within {@linkcode Manifest.syncWithInstalledExtensions}; the extensions
28
+ * will be checked and the manifest file updated per the state of the filesystem.
29
+ *
30
+ * @type { {[P in keyof ManifestDataVersions]?: Migration} }
31
+ */
32
+ const Migrations = {
33
+ /**
34
+ * If `installPath` is missing from the `ExtManifest` for any extension, return `true`.
35
+ *
36
+ * We cannot easily determine the path of any given extension here, but returning `true`
37
+ * will cause the `Manifest` to sync with the filesystem, which will populate the missing field.
38
+ *
39
+ * @type {Migration}
40
+ */
41
+ [SCHEMA_REV_3]: (manifest) => {
42
+ /** @type {Array<ExtManifest<PluginType>|ExtManifest<DriverType>>} */
43
+ const allExtData = [
44
+ ...Object.values(manifest.getExtensionData(constants_1.DRIVER_TYPE)),
45
+ ...Object.values(manifest.getExtensionData(constants_1.PLUGIN_TYPE)),
46
+ ];
47
+ return allExtData.some((metadata) => !('installPath' in metadata));
48
+ },
49
+ /**
50
+ * Updates installed extensions to use `InstallType` of `dev` if appropriate.
51
+ *
52
+ * Previously, these types of extensions (automatically discovered) would use the default `InstallType` of `npm`, so we need
53
+ * to refresh any with this install type.
54
+ *
55
+ * This should only happen once; we do not want to re-check everything with `npm` install type
56
+ * every time.
57
+ * @type {Migration}
58
+ */
59
+ [SCHEMA_REV_4]: (manifest) => {
60
+ if (manifest.schemaRev < SCHEMA_REV_4) {
61
+ const allExtData = [
62
+ ...Object.values(manifest.getExtensionData(constants_1.DRIVER_TYPE)),
63
+ ...Object.values(manifest.getExtensionData(constants_1.PLUGIN_TYPE)),
64
+ ];
65
+ return allExtData.some((metadata) => metadata.installType === 'npm');
66
+ }
67
+ return false;
68
+ },
69
+ };
70
+ /**
71
+ * Set `schemaRev` to a specific version.
72
+ *
73
+ * This _does_ mutate `data` in-place, unlike functions in
74
+ * {@linkcode Migrations}.
75
+ *
76
+ * Again, returning `true` means that the manifest should be--at
77
+ * minimum--persisted to disk, since we changed it.
78
+ * @param {Readonly<Manifest>} manifest
79
+ * @param {keyof ManifestDataVersions} version
80
+ * @returns {boolean} Whether the data was modified
81
+ */
82
+ function setSchemaRev(manifest, version) {
83
+ if ((manifest.schemaRev ?? 0) < version) {
84
+ manifest.setSchemaRev(version);
85
+ return true;
86
+ }
87
+ return false;
88
+ }
89
+ /**
90
+ * Applies a series of migration functions to a manifest to update its manifest schema version.
91
+ *
92
+ * `data` is modified in-place.
93
+ *
94
+ * @param {Readonly<Manifest>} manifest
95
+ * @returns {Promise<boolean>} If `true` existing packages should be synced from disk and the manifest should be persisted.
96
+ */
97
+ async function migrate(manifest) {
98
+ let didChange = false;
99
+ for await (const migration of Object.values(Migrations)) {
100
+ didChange = (await migration(manifest)) || didChange;
101
+ }
102
+ didChange = setSchemaRev(manifest, constants_1.CURRENT_SCHEMA_REV) || didChange;
103
+ if (didChange) {
104
+ // this is not _technically_ true, since we don't actually write the file here.
105
+ logger_1.default.debug(`Upgraded extension manifest to schema v${manifest.schemaRev}`);
106
+ }
107
+ return didChange;
108
+ }
109
+ exports.migrate = migrate;
110
+ /**
111
+ * A migration function. It will return `true` if a change _should be made_.
112
+ *
113
+ * A migration function should not modify `schemaRev`, as this is done automatically.
114
+ *
115
+ * Note that at the time of writing, we're not able to determine the version of the _current_ manifest file if there is no `schemaRev` prop present (and we may not want to trust it anyway).
116
+ * @callback Migration
117
+ * @param {Readonly<Manifest>} manifest - The `Manifest` instance
118
+ * @returns {boolean|Promise<boolean>} If `true`, then something changed
119
+ */
120
+ /**
121
+ * @typedef {import('appium/types').ManifestData} ManifestData
122
+ * @typedef {import('@appium/types').DriverType} DriverType
123
+ * @typedef {import('@appium/types').PluginType} PluginType
124
+ * @typedef {import('appium/types').AnyManifestDataVersion} AnyManifestDataVersion
125
+ * @typedef {import('appium/types').ManifestDataVersions} ManifestDataVersions
126
+ * @typedef {import('@appium/types').ExtensionType} ExtensionType
127
+ * @typedef {import('appium/types').ManifestV2.ManifestData} ManifestDataV2
128
+ * @typedef {import('./manifest').Manifest} Manifest
129
+ */
130
+ /**
131
+ * @template {ExtensionType} ExtType
132
+ * @typedef {import('appium/types').ExtManifest<ExtType>} ExtManifest
133
+ */
134
+ //# sourceMappingURL=manifest-migrations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest-migrations.js","sourceRoot":"","sources":["../../../lib/extension/manifest-migrations.js"],"names":[],"mappings":";;;;;;AAAA,4CAA0E;AAC1E,uDAA4B;AAE5B;;;;GAIG;AAEH;;GAEG;AACH,MAAM,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,CAAC;KACb;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;GAOG;AACI,KAAK,UAAU,OAAO,CAAC,QAAQ;IACpC,IAAI,SAAS,GAAG,KAAK,CAAC;IACtB,IAAI,KAAK,EAAE,MAAM,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,EAAE;QACvD,SAAS,GAAG,CAAC,MAAM,SAAS,CAAC,QAAQ,CAAC,CAAC,IAAI,SAAS,CAAC;KACtD;IACD,SAAS,GAAG,YAAY,CAAC,QAAQ,EAAE,8BAAkB,CAAC,IAAI,SAAS,CAAC;IACpE,IAAI,SAAS,EAAE;QACb,+EAA+E;QAC/E,gBAAG,CAAC,KAAK,CAAC,0CAA0C,QAAQ,CAAC,SAAS,EAAE,CAAC,CAAC;KAC3E;IAED,OAAO,SAAS,CAAC;AACnB,CAAC;AAZD,0BAYC;AAED;;;;;;;;;GASG;AAEH;;;;;;;;;GASG;AAEH;;;GAGG"}
@@ -0,0 +1,145 @@
1
+ /**
2
+ * Handles reading & writing of extension config files.
3
+ *
4
+ * Only one instance of this class exists per value of `APPIUM_HOME`.
5
+ */
6
+ export class Manifest {
7
+ /**
8
+ * Returns a new or existing {@link Manifest} instance, based on the value of `appiumHome`.
9
+ *
10
+ * Maintains one instance per value of `appiumHome`.
11
+ */
12
+ static getInstance: ((appiumHome: string) => Manifest) & _.MemoizedFunction;
13
+ /**
14
+ * Sets internal data to a fresh clone of {@link INITIAL_MANIFEST_DATA}
15
+ *
16
+ * Use {@link Manifest.getInstance} instead.
17
+ * @param {string} appiumHome
18
+ * @private
19
+ */
20
+ private constructor();
21
+ /**
22
+ * Searches `APPIUM_HOME` for installed extensions and adds them to the manifest.
23
+ * @param {boolean} hasAppiumDependency - This affects whether or not the "dev" `InstallType` is used
24
+ * @returns {Promise<boolean>} `true` if any extensions were added, `false` otherwise.
25
+ */
26
+ syncWithInstalledExtensions(hasAppiumDependency?: boolean): Promise<boolean>;
27
+ /**
28
+ * Returns `true` if driver with name `name` is registered.
29
+ * @param {string} name - Driver name
30
+ * @returns {boolean}
31
+ */
32
+ hasDriver(name: string): boolean;
33
+ /**
34
+ * Returns `true` if plugin with name `name` is registered.
35
+ * @param {string} name - Plugin name
36
+ * @returns {boolean}
37
+ */
38
+ hasPlugin(name: string): boolean;
39
+ /**
40
+ * Given a path to a `package.json`, add it as either a driver or plugin to the manifest.
41
+ *
42
+ * @template {ExtensionType} ExtType
43
+ * @param {ExtPackageJson<ExtType>} pkgJson
44
+ * @param {string} pkgPath
45
+ * @param {typeof INSTALL_TYPE_NPM | typeof INSTALL_TYPE_DEV} [installType]
46
+ * @returns {boolean} - `true` if this method did anything.
47
+ */
48
+ addExtensionFromPackage<ExtType extends import("@appium/types").ExtensionType>(pkgJson: ExtPackageJson<ExtType>, pkgPath: string, installType?: "npm" | "dev" | undefined): boolean;
49
+ /**
50
+ * Adds an extension to the manifest as was installed by the `appium` CLI. The
51
+ * `extData`, `extType`, and `extName` have already been determined.
52
+ *
53
+ * See {@link Manifest.addExtensionFromPackage} for adding an extension from an on-disk package.
54
+ * @template {ExtensionType} ExtType
55
+ * @param {ExtType} extType - `driver` or `plugin`
56
+ * @param {string} extName - Name of extension
57
+ * @param {ExtManifest<ExtType>} extData - Extension metadata
58
+ * @returns {ExtManifest<ExtType>} A clone of `extData`, potentially with a mutated `appiumVersion` field
59
+ */
60
+ setExtension<ExtType_1 extends import("@appium/types").ExtensionType>(extType: ExtType_1, extName: string, extData: ExtManifest<ExtType_1>): ExtManifest<ExtType_1>;
61
+ /**
62
+ * Sets the schema revision
63
+ * @param {keyof import('./manifest-migrations').ManifestDataVersions} rev
64
+ */
65
+ setSchemaRev(rev: keyof import('./manifest-migrations').ManifestDataVersions): void;
66
+ /**
67
+ * Remove an extension from the manifest.
68
+ * @param {ExtensionType} extType
69
+ * @param {string} extName
70
+ */
71
+ deleteExtension(extType: ExtensionType, extName: string): void;
72
+ /**
73
+ * Returns the `APPIUM_HOME` path
74
+ */
75
+ get appiumHome(): string;
76
+ /**
77
+ * Returns the path to the manifest file (`extensions.yaml`)
78
+ */
79
+ get manifestPath(): string;
80
+ /**
81
+ * Returns the schema rev of this manifest
82
+ */
83
+ get schemaRev(): number;
84
+ /**
85
+ * Returns extension data for a particular type.
86
+ *
87
+ * @template {ExtensionType} ExtType
88
+ * @param {ExtType} extType
89
+ * @returns {Readonly<ExtRecord<ExtType>>}
90
+ */
91
+ getExtensionData<ExtType_2 extends import("@appium/types").ExtensionType>(extType: ExtType_2): Readonly<ExtRecord<ExtType_2>>;
92
+ /**
93
+ * Reads manifest from disk and _overwrites_ the internal data.
94
+ *
95
+ * If the manifest does not exist on disk, an
96
+ * {@link INITIAL_MANIFEST_DATA "empty"} manifest file will be created, as
97
+ * well as its directory if needed.
98
+ *
99
+ * This will also, if necessary:
100
+ * 1. perform a migration of the manifest data
101
+ * 2. sync the manifest with extensions on-disk (kind of like "auto
102
+ * discovery")
103
+ * 3. write the manifest to disk.
104
+ *
105
+ * Only one read operation can happen at a time.
106
+ *
107
+ * @returns {Promise<ManifestData>} The data
108
+ */
109
+ read(): Promise<ManifestData>;
110
+ /**
111
+ * Writes the data if it need s writing.
112
+ *
113
+ * If the `schemaRev` prop needs updating, the file will be written.
114
+ *
115
+ * @todo If this becomes too much of a bottleneck, throttle it.
116
+ * @returns {Promise<boolean>} Whether the data was written
117
+ */
118
+ write(): Promise<boolean>;
119
+ #private;
120
+ }
121
+ /**
122
+ * Type of the string referring to a driver (typically as a key or type string)
123
+ */
124
+ export type DriverType = import('@appium/types').DriverType;
125
+ /**
126
+ * Type of the string referring to a plugin (typically as a key or type string)
127
+ */
128
+ export type PluginType = import('@appium/types').PluginType;
129
+ export type SyncWithInstalledExtensionsOpts = {
130
+ /**
131
+ * - Maximum depth to recurse into subdirectories
132
+ */
133
+ depthLimit?: number | undefined;
134
+ };
135
+ export type ManifestData = import('appium/types').ManifestData;
136
+ export type InternalMetadata = import('appium/types').InternalMetadata;
137
+ export type ExtPackageJson<ExtType extends import("@appium/types").ExtensionType> = import('appium/types').ExtPackageJson<ExtType>;
138
+ export type ExtManifest<ExtType extends import("@appium/types").ExtensionType> = import('appium/types').ExtManifest<ExtType>;
139
+ export type ExtRecord<ExtType extends import("@appium/types").ExtensionType> = import('appium/types').ExtRecord<ExtType>;
140
+ /**
141
+ * Either `driver` or `plugin` rn
142
+ */
143
+ export type ExtensionType = import('@appium/types').ExtensionType;
144
+ import _ from "lodash";
145
+ //# sourceMappingURL=manifest.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"manifest.d.ts","sourceRoot":"","sources":["../../../lib/extension/manifest.js"],"names":[],"mappings":"AAqFA;;;;GAIG;AACH;IAwDE;;;;OAIG;IACH,kCAEa,MAAM,KACJ,QAAQ,uBAKrB;IAzBF;;;;;;OAMG;IACH,sBAGC;IAiBD;;;;OAIG;IACH,kDAHW,OAAO,GACL,QAAQ,OAAO,CAAC,CAwE5B;IAED;;;;OAIG;IACH,gBAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;OAIG;IACH,gBAHW,MAAM,GACJ,OAAO,CAInB;IAED;;;;;;;;OAQG;IACH,0HAJW,MAAM,4CAEJ,OAAO,CA0CnB;IAED;;;;;;;;;;OAUG;IACH,mGAJW,MAAM,2DAQhB;IAED;;;OAGG;IACH,kBAFW,MAAM,OAAO,uBAAuB,EAAE,oBAAoB,QAIpE;IAED;;;;OAIG;IACH,yBAHW,aAAa,WACb,MAAM,QAIhB;IAED;;OAEG;IACH,yBAEC;IAED;;OAEG;IACH,2BAEC;IAED;;OAEG;IACH,wBAEC;IAED;;;;;;OAMG;IACH,8HAEC;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,QAFa,QAAQ,YAAY,CAAC,CAsFjC;IAyBD;;;;;;;OAOG;IACH,SAFa,QAAQ,OAAO,CAAC,CAiC5B;;CACF;;;;yBAIY,OAAO,eAAe,EAAE,UAAU;;;;yBAKlC,OAAO,eAAe,EAAE,UAAU;;;;;;;2BASlC,OAAO,cAAc,EAAE,YAAY;+BACnC,OAAO,cAAc,EAAE,gBAAgB;oFAKvC,OAAO,cAAc,EAAE,cAAc,CAAC,OAAO,CAAC;iFAK9C,OAAO,cAAc,EAAE,WAAW,CAAC,OAAO,CAAC;+EAK3C,OAAO,cAAc,EAAE,SAAS,CAAC,OAAO,CAAC;;;;4BAKzC,OAAO,eAAe,EAAE,aAAa"}