appium 2.0.0-beta.7 → 2.0.0-beta.71
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/LICENSE +1 -1
- package/README.md +149 -58
- package/build/lib/appium.d.ts +229 -0
- package/build/lib/appium.d.ts.map +1 -0
- package/build/lib/appium.js +678 -439
- package/build/lib/appium.js.map +1 -0
- package/build/lib/cli/args.d.ts +17 -0
- package/build/lib/cli/args.d.ts.map +1 -0
- package/build/lib/cli/args.js +263 -300
- package/build/lib/cli/args.js.map +1 -0
- package/build/lib/cli/driver-command.d.ts +102 -0
- package/build/lib/cli/driver-command.d.ts.map +1 -0
- package/build/lib/cli/driver-command.js +131 -81
- package/build/lib/cli/driver-command.js.map +1 -0
- package/build/lib/cli/extension-command.d.ts +402 -0
- package/build/lib/cli/extension-command.d.ts.map +1 -0
- package/build/lib/cli/extension-command.js +799 -383
- package/build/lib/cli/extension-command.js.map +1 -0
- package/build/lib/cli/extension.d.ts +23 -0
- package/build/lib/cli/extension.d.ts.map +1 -0
- package/build/lib/cli/extension.js +71 -60
- package/build/lib/cli/extension.js.map +1 -0
- package/build/lib/cli/parser.d.ts +84 -0
- package/build/lib/cli/parser.d.ts.map +1 -0
- package/build/lib/cli/parser.js +252 -148
- package/build/lib/cli/parser.js.map +1 -0
- package/build/lib/cli/plugin-command.d.ts +99 -0
- package/build/lib/cli/plugin-command.d.ts.map +1 -0
- package/build/lib/cli/plugin-command.js +125 -81
- package/build/lib/cli/plugin-command.js.map +1 -0
- 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 +72 -51
- package/build/lib/cli/utils.js.map +1 -0
- 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 +207 -0
- package/build/lib/config-file.js.map +1 -0
- package/build/lib/config.d.ts +49 -0
- package/build/lib/config.d.ts.map +1 -0
- package/build/lib/config.js +262 -223
- package/build/lib/config.js.map +1 -0
- package/build/lib/constants.d.ts +56 -0
- package/build/lib/constants.d.ts.map +1 -0
- package/build/lib/constants.js +73 -0
- package/build/lib/constants.js.map +1 -0
- package/build/lib/extension/driver-config.d.ts +82 -0
- package/build/lib/extension/driver-config.d.ts.map +1 -0
- package/build/lib/extension/driver-config.js +210 -0
- package/build/lib/extension/driver-config.js.map +1 -0
- package/build/lib/extension/extension-config.d.ts +270 -0
- package/build/lib/extension/extension-config.d.ts.map +1 -0
- package/build/lib/extension/extension-config.js +601 -0
- package/build/lib/extension/extension-config.js.map +1 -0
- package/build/lib/extension/index.d.ts +48 -0
- package/build/lib/extension/index.d.ts.map +1 -0
- package/build/lib/extension/index.js +105 -0
- package/build/lib/extension/index.js.map +1 -0
- package/build/lib/extension/manifest-migrations.d.ts +27 -0
- package/build/lib/extension/manifest-migrations.d.ts.map +1 -0
- package/build/lib/extension/manifest-migrations.js +134 -0
- package/build/lib/extension/manifest-migrations.js.map +1 -0
- package/build/lib/extension/manifest.d.ts +145 -0
- package/build/lib/extension/manifest.d.ts.map +1 -0
- package/build/lib/extension/manifest.js +528 -0
- package/build/lib/extension/manifest.js.map +1 -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 +62 -0
- package/build/lib/extension/package-changed.js.map +1 -0
- package/build/lib/extension/plugin-config.d.ts +56 -0
- package/build/lib/extension/plugin-config.d.ts.map +1 -0
- package/build/lib/extension/plugin-config.js +102 -0
- package/build/lib/extension/plugin-config.js.map +1 -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 +122 -144
- package/build/lib/grid-register.js.map +1 -0
- package/build/lib/logger.d.ts +3 -0
- package/build/lib/logger.d.ts.map +1 -0
- package/build/lib/logger.js +5 -17
- package/build/lib/logger.js.map +1 -0
- package/build/lib/logsink.d.ts +4 -0
- package/build/lib/logsink.d.ts.map +1 -0
- package/build/lib/logsink.js +189 -184
- package/build/lib/logsink.js.map +1 -0
- package/build/lib/main.d.ts +62 -0
- package/build/lib/main.d.ts.map +1 -0
- package/build/lib/main.js +388 -234
- package/build/lib/main.js.map +1 -0
- 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 +164 -0
- package/build/lib/schema/arg-spec.js.map +1 -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 +220 -0
- package/build/lib/schema/cli-args.js.map +1 -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 +124 -0
- package/build/lib/schema/cli-transformers.js.map +1 -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 +19 -0
- package/build/lib/schema/index.js.map +1 -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 +128 -0
- package/build/lib/schema/keywords.js.map +1 -0
- package/build/lib/schema/schema.d.ts +260 -0
- package/build/lib/schema/schema.d.ts.map +1 -0
- package/build/lib/schema/schema.js +640 -0
- package/build/lib/schema/schema.js.map +1 -0
- package/build/lib/utils.d.ts +266 -0
- package/build/lib/utils.d.ts.map +1 -0
- package/build/lib/utils.js +349 -273
- package/build/lib/utils.js.map +1 -0
- package/build/types/cli.d.ts +134 -0
- package/build/types/cli.d.ts.map +1 -0
- package/build/types/cli.js +3 -0
- package/build/types/cli.js.map +1 -0
- package/build/types/index.d.ts +15 -0
- package/build/types/index.d.ts.map +1 -0
- package/build/types/index.js +19 -0
- package/build/types/index.js.map +1 -0
- package/build/types/manifest/base.d.ts +135 -0
- package/build/types/manifest/base.d.ts.map +1 -0
- package/build/types/manifest/base.js +3 -0
- package/build/types/manifest/base.js.map +1 -0
- package/build/types/manifest/index.d.ts +21 -0
- package/build/types/manifest/index.d.ts.map +1 -0
- package/build/types/manifest/index.js +42 -0
- package/build/types/manifest/index.js.map +1 -0
- package/build/types/manifest/v3.d.ts +139 -0
- package/build/types/manifest/v3.d.ts.map +1 -0
- package/build/types/manifest/v3.js +3 -0
- package/build/types/manifest/v3.js.map +1 -0
- package/build/types/manifest/v4.d.ts +139 -0
- package/build/types/manifest/v4.d.ts.map +1 -0
- package/build/types/manifest/v4.js +3 -0
- package/build/types/manifest/v4.js.map +1 -0
- package/driver.d.ts +1 -0
- package/driver.js +14 -0
- package/index.js +11 -0
- package/lib/appium.js +558 -186
- package/lib/cli/args.js +275 -407
- package/lib/cli/driver-command.js +132 -24
- package/lib/cli/extension-command.js +751 -272
- package/lib/cli/extension.js +47 -20
- package/lib/cli/parser.js +267 -95
- package/lib/cli/plugin-command.js +122 -22
- package/lib/cli/utils.js +24 -10
- package/lib/config-file.js +220 -0
- package/lib/config.js +243 -132
- package/lib/constants.js +79 -0
- package/lib/extension/driver-config.js +247 -0
- package/lib/extension/extension-config.js +709 -0
- package/lib/extension/index.js +116 -0
- package/lib/extension/manifest-migrations.js +136 -0
- package/lib/extension/manifest.js +580 -0
- package/lib/extension/package-changed.js +64 -0
- package/lib/extension/plugin-config.js +112 -0
- package/lib/grid-register.js +49 -35
- package/lib/logger.js +1 -2
- package/lib/logsink.js +59 -36
- package/lib/main.js +369 -104
- package/lib/schema/arg-spec.js +229 -0
- package/lib/schema/cli-args.js +241 -0
- package/lib/schema/cli-transformers.js +119 -0
- package/lib/schema/index.js +2 -0
- package/lib/schema/keywords.js +136 -0
- package/lib/schema/schema.js +725 -0
- package/lib/utils.js +289 -167
- package/package.json +84 -83
- package/plugin.d.ts +1 -0
- package/plugin.js +13 -0
- package/scripts/autoinstall-extensions.js +243 -0
- package/support.d.ts +1 -0
- package/support.js +13 -0
- package/tsconfig.json +25 -0
- package/types/cli.ts +193 -0
- package/types/index.ts +20 -0
- package/types/manifest/README.md +30 -0
- package/types/manifest/base.ts +158 -0
- package/types/manifest/index.ts +28 -0
- package/types/manifest/v3.ts +161 -0
- package/types/manifest/v4.ts +161 -0
- package/CHANGELOG.md +0 -3594
- package/bin/ios-webkit-debug-proxy-launcher.js +0 -71
- package/build/lib/cli/argparse-actions.js +0 -104
- package/build/lib/cli/npm.js +0 -200
- package/build/lib/cli/parser-helpers.js +0 -93
- package/build/lib/driver-config.js +0 -77
- package/build/lib/drivers.js +0 -99
- package/build/lib/extension-config.js +0 -253
- package/build/lib/plugin-config.js +0 -59
- package/build/lib/plugins.js +0 -14
- package/lib/cli/argparse-actions.js +0 -77
- package/lib/cli/npm.js +0 -175
- package/lib/cli/parser-helpers.js +0 -91
- package/lib/driver-config.js +0 -46
- package/lib/drivers.js +0 -84
- package/lib/extension-config.js +0 -209
- package/lib/plugin-config.js +0 -34
- package/lib/plugins.js +0 -10
|
@@ -1,85 +1,129 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
require("source-map-support/register");
|
|
11
|
-
|
|
12
|
-
var _lodash = _interopRequireDefault(require("lodash"));
|
|
13
|
-
|
|
14
|
-
var _extensionCommand = _interopRequireDefault(require("./extension-command"));
|
|
15
|
-
|
|
16
|
-
var _extensionConfig = require("../extension-config");
|
|
17
|
-
|
|
18
|
-
var _plugins = require("../plugins");
|
|
19
|
-
|
|
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
|
+
const lodash_1 = __importDefault(require("lodash"));
|
|
7
|
+
const extension_command_1 = __importDefault(require("./extension-command"));
|
|
8
|
+
const constants_1 = require("../constants");
|
|
20
9
|
const REQ_PLUGIN_FIELDS = ['pluginName', 'mainClass'];
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
})
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
10
|
+
/**
|
|
11
|
+
* @extends {ExtensionCliCommand<PluginType>}
|
|
12
|
+
*/
|
|
13
|
+
class PluginCliCommand extends extension_command_1.default {
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param {import('./extension-command').ExtensionCommandOptions<PluginType>} opts
|
|
17
|
+
*/
|
|
18
|
+
constructor({ config, json }) {
|
|
19
|
+
super({ config, json });
|
|
20
|
+
this.knownExtensions = constants_1.KNOWN_PLUGINS;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Install a plugin
|
|
24
|
+
*
|
|
25
|
+
* @param {PluginInstallOpts} opts
|
|
26
|
+
* @returns {Promise<ExtRecord<PluginType>>}
|
|
27
|
+
*/
|
|
28
|
+
async install({ plugin, installType, packageName }) {
|
|
29
|
+
return await super._install({
|
|
30
|
+
installSpec: plugin,
|
|
31
|
+
installType,
|
|
32
|
+
packageName,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Uninstall a plugin
|
|
37
|
+
*
|
|
38
|
+
* @param {PluginUninstallOpts} opts
|
|
39
|
+
* @returns {Promise<ExtRecord<PluginType>>}
|
|
40
|
+
*/
|
|
41
|
+
async uninstall({ plugin }) {
|
|
42
|
+
return await super._uninstall({ installSpec: plugin });
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Update a plugin
|
|
46
|
+
*
|
|
47
|
+
* @param {PluginUpdateOpts} opts
|
|
48
|
+
* @returns {Promise<import('./extension-command').ExtensionUpdateResult>}
|
|
49
|
+
*/
|
|
50
|
+
async update({ plugin, unsafe }) {
|
|
51
|
+
return await super._update({ installSpec: plugin, unsafe });
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
*
|
|
55
|
+
* @param {PluginRunOptions} opts
|
|
56
|
+
* @returns {Promise<import('./extension-command').RunOutput>}
|
|
57
|
+
*/
|
|
58
|
+
async run({ plugin, scriptName, extraArgs }) {
|
|
59
|
+
return await super._run({
|
|
60
|
+
installSpec: plugin,
|
|
61
|
+
scriptName,
|
|
62
|
+
extraArgs,
|
|
63
|
+
bufferOutput: this.isJsonOutput,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* @param {import('./extension-command').ExtensionArgs} opts
|
|
69
|
+
* @returns {string}
|
|
70
|
+
*/
|
|
71
|
+
getPostInstallText({ extName, extData }) {
|
|
72
|
+
return `Plugin ${extName}@${extData.version} successfully installed`.green;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Validates fields in `appium` field of `pluginMetadata`
|
|
76
|
+
*
|
|
77
|
+
* For any `package.json` fields which a plugin requires, validate the type of
|
|
78
|
+
* those fields on the `package.json` data, throwing an error if anything is
|
|
79
|
+
* amiss.
|
|
80
|
+
* @param {import('appium/types').ExtMetadata<PluginType>} pluginMetadata
|
|
81
|
+
* @param {string} installSpec
|
|
82
|
+
* @returns {void}
|
|
83
|
+
*/
|
|
84
|
+
validateExtensionFields(pluginMetadata, installSpec) {
|
|
85
|
+
const missingFields = REQ_PLUGIN_FIELDS.reduce((acc, field) => (pluginMetadata[field] ? acc : [...acc, field]), []);
|
|
86
|
+
if (!lodash_1.default.isEmpty(missingFields)) {
|
|
87
|
+
throw new Error(`Installed plugin "${installSpec}" did not expose correct fields for compability ` +
|
|
88
|
+
`with Appium. Missing fields: ${JSON.stringify(missingFields)}`);
|
|
89
|
+
}
|
|
77
90
|
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
91
|
}
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
92
|
+
exports.default = PluginCliCommand;
|
|
93
|
+
/**
|
|
94
|
+
* @typedef {import('@appium/types').ExtensionType} ExtensionType
|
|
95
|
+
* @typedef {import('@appium/types').PluginType} PluginType
|
|
96
|
+
*/
|
|
97
|
+
/**
|
|
98
|
+
* @template {ExtensionType} ExtType
|
|
99
|
+
* @typedef {import('appium/types').ExtRecord<ExtType>} ExtRecord
|
|
100
|
+
*/
|
|
101
|
+
/**
|
|
102
|
+
* Options for {@linkcode PluginCliCommand.install}
|
|
103
|
+
* @typedef PluginInstallOpts
|
|
104
|
+
* @property {string} plugin - the name or spec of a plugin to install
|
|
105
|
+
* @property {InstallType} installType - how to install this plugin. One of the INSTALL_TYPES
|
|
106
|
+
* @property {string} [packageName] - for git/github installs, the plugin node package name
|
|
107
|
+
*/
|
|
108
|
+
/**
|
|
109
|
+
* @typedef {import('appium/types').InstallType} InstallType
|
|
110
|
+
*/
|
|
111
|
+
/**
|
|
112
|
+
* Options for {@linkcode PluginCliCommand.uninstall}
|
|
113
|
+
* @typedef PluginUninstallOpts
|
|
114
|
+
* @property {string} plugin - the name or spec of a plugin to uninstall
|
|
115
|
+
*/
|
|
116
|
+
/**
|
|
117
|
+
* Options for {@linkcode PluginCliCommand.update}
|
|
118
|
+
* @typedef PluginUpdateOpts
|
|
119
|
+
* @property {string} plugin - the name of the plugin to update
|
|
120
|
+
* @property {boolean} unsafe - if true, will perform unsafe updates past major revision boundaries
|
|
121
|
+
*/
|
|
122
|
+
/**
|
|
123
|
+
* Options for {@linkcode PluginCliCommand.run}.
|
|
124
|
+
* @typedef PluginRunOptions
|
|
125
|
+
* @property {string} plugin - name of the plugin to run a script from
|
|
126
|
+
* @property {string} scriptName - name of the script to run
|
|
127
|
+
* @property {string[]} [extraArgs] - arguments to pass to the script
|
|
128
|
+
*/
|
|
129
|
+
//# sourceMappingURL=plugin-command.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"plugin-command.js","sourceRoot":"","sources":["../../../lib/cli/plugin-command.js"],"names":[],"mappings":";;;;;AAAA,oDAAuB;AACvB,4EAAsD;AACtD,4CAA2C;AAE3C,MAAM,iBAAiB,GAAG,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAqB,gBAAiB,SAAQ,2BAAmB;IAC/D;;;OAGG;IACH,YAAY,EAAC,MAAM,EAAE,IAAI,EAAC;QACxB,KAAK,CAAC,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC,CAAC;QACtB,IAAI,CAAC,eAAe,GAAG,yBAAa,CAAC;IACvC,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,OAAO,CAAC,EAAC,MAAM,EAAE,WAAW,EAAE,WAAW,EAAC;QAC9C,OAAO,MAAM,KAAK,CAAC,QAAQ,CAAC;YAC1B,WAAW,EAAE,MAAM;YACnB,WAAW;YACX,WAAW;SACZ,CAAC,CAAC;IACL,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,SAAS,CAAC,EAAC,MAAM,EAAC;QACtB,OAAO,MAAM,KAAK,CAAC,UAAU,CAAC,EAAC,WAAW,EAAE,MAAM,EAAC,CAAC,CAAC;IACvD,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,MAAM,CAAC,EAAC,MAAM,EAAE,MAAM,EAAC;QAC3B,OAAO,MAAM,KAAK,CAAC,OAAO,CAAC,EAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAC,CAAC,CAAC;IAC5D,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,GAAG,CAAC,EAAC,MAAM,EAAE,UAAU,EAAE,SAAS,EAAC;QACvC,OAAO,MAAM,KAAK,CAAC,IAAI,CAAC;YACtB,WAAW,EAAE,MAAM;YACnB,UAAU;YACV,SAAS;YACT,YAAY,EAAE,IAAI,CAAC,YAAY;SAChC,CAAC,CAAC;IACL,CAAC;IAED;;;;OAIG;IACH,kBAAkB,CAAC,EAAC,OAAO,EAAE,OAAO,EAAC;QACnC,OAAO,UAAU,OAAO,IAAI,OAAO,CAAC,OAAO,yBAAyB,CAAC,KAAK,CAAC;IAC7E,CAAC;IAED;;;;;;;;;OASG;IACH,uBAAuB,CAAC,cAAc,EAAE,WAAW;QACjD,MAAM,aAAa,GAAG,iBAAiB,CAAC,MAAM,CAC5C,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,GAAG,EAAE,KAAK,CAAC,CAAC,EAC/D,EAAE,CACH,CAAC;QAEF,IAAI,CAAC,gBAAC,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE;YAC7B,MAAM,IAAI,KAAK,CACb,qBAAqB,WAAW,kDAAkD;gBAChF,gCAAgC,IAAI,CAAC,SAAS,CAAC,aAAa,CAAC,EAAE,CAClE,CAAC;SACH;IACH,CAAC;CACF;AA1FD,mCA0FC;AAED;;;GAGG;AAEH;;;GAGG;AAEH;;;;;;GAMG;AAEH;;GAEG;AAEH;;;;GAIG;AAEH;;;;;GAKG;AAEH;;;;;;GAMG"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/***
|
|
2
|
+
* Log an error to the console and exit the process.
|
|
3
|
+
* @param {boolean} json - whether we should log json or text
|
|
4
|
+
* @param {any} msg - error message, object, Error instance, etc.
|
|
5
|
+
*/
|
|
6
|
+
export function errAndQuit(json: boolean, msg: any): void;
|
|
7
|
+
/**
|
|
8
|
+
* Conditionally log something to the console
|
|
9
|
+
* @param {boolean} json - whether we are in json mode (and should therefore not log)
|
|
10
|
+
* @param {string} msg - string to log
|
|
11
|
+
*/
|
|
12
|
+
export function log(json: boolean, msg: string): void;
|
|
13
|
+
/**
|
|
14
|
+
* Start a spinner, execute an async function, and then stop the spinner
|
|
15
|
+
* @param {boolean} json - whether we are in json mode (and should therefore not log)
|
|
16
|
+
* @param {string} msg - string to log
|
|
17
|
+
* @param {function} fn - function to wrap with spinning
|
|
18
|
+
*/
|
|
19
|
+
export function spinWith(json: boolean, msg: string, fn: Function): Promise<any>;
|
|
20
|
+
export const JSON_SPACES: 4;
|
|
21
|
+
export class RingBuffer {
|
|
22
|
+
constructor(size?: number);
|
|
23
|
+
size: number;
|
|
24
|
+
buffer: any[];
|
|
25
|
+
getBuff(): any[];
|
|
26
|
+
dequeue(): void;
|
|
27
|
+
enqueue(item: any): void;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../lib/cli/utils.js"],"names":[],"mappings":"AAMA;;;;GAIG;AACH,iCAHW,OAAO,OACP,GAAG,QAYb;AAED;;;;GAIG;AACH,0BAHW,OAAO,OACP,MAAM,QAIhB;AAED;;;;;GAKG;AACH,+BAJW,OAAO,OACP,MAAM,8BAiBhB;AAhDD,4BAAsB;AAkDtB;IACE,2BAGC;IAFC,aAAgB;IAChB,cAAgB;IAElB,iBAEC;IACD,gBAEC;IACD,yBAKC;CACF"}
|
package/build/lib/cli/utils.js
CHANGED
|
@@ -1,59 +1,80 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
exports.log = log;
|
|
10
|
-
exports.spinWith = spinWith;
|
|
11
|
-
exports.JSON_SPACES = void 0;
|
|
12
|
-
|
|
13
|
-
require("source-map-support/register");
|
|
14
|
-
|
|
15
|
-
var _ora = _interopRequireDefault(require("ora"));
|
|
16
|
-
|
|
2
|
+
/* eslint-disable no-console */
|
|
3
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
+
};
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.RingBuffer = exports.JSON_SPACES = exports.spinWith = exports.log = exports.errAndQuit = void 0;
|
|
8
|
+
const ora_1 = __importDefault(require("ora"));
|
|
17
9
|
const JSON_SPACES = 4;
|
|
18
10
|
exports.JSON_SPACES = JSON_SPACES;
|
|
19
|
-
|
|
11
|
+
/***
|
|
12
|
+
* Log an error to the console and exit the process.
|
|
13
|
+
* @param {boolean} json - whether we should log json or text
|
|
14
|
+
* @param {any} msg - error message, object, Error instance, etc.
|
|
15
|
+
*/
|
|
20
16
|
function errAndQuit(json, msg) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
process.exit(1);
|
|
17
|
+
if (json) {
|
|
18
|
+
console.log(JSON.stringify({ error: `${msg}` }, null, JSON_SPACES));
|
|
19
|
+
}
|
|
20
|
+
else {
|
|
21
|
+
console.error(`${msg}`.red);
|
|
22
|
+
if (msg.stderr) {
|
|
23
|
+
console.error(`${msg.stderr}`.red);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
process.exit(1);
|
|
34
27
|
}
|
|
35
|
-
|
|
28
|
+
exports.errAndQuit = errAndQuit;
|
|
29
|
+
/**
|
|
30
|
+
* Conditionally log something to the console
|
|
31
|
+
* @param {boolean} json - whether we are in json mode (and should therefore not log)
|
|
32
|
+
* @param {string} msg - string to log
|
|
33
|
+
*/
|
|
36
34
|
function log(json, msg) {
|
|
37
|
-
|
|
35
|
+
!json && console.log(msg);
|
|
38
36
|
}
|
|
39
|
-
|
|
37
|
+
exports.log = log;
|
|
38
|
+
/**
|
|
39
|
+
* Start a spinner, execute an async function, and then stop the spinner
|
|
40
|
+
* @param {boolean} json - whether we are in json mode (and should therefore not log)
|
|
41
|
+
* @param {string} msg - string to log
|
|
42
|
+
* @param {function} fn - function to wrap with spinning
|
|
43
|
+
*/
|
|
40
44
|
async function spinWith(json, msg, fn) {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
45
|
+
if (json) {
|
|
46
|
+
return await fn();
|
|
47
|
+
}
|
|
48
|
+
const spinner = (0, ora_1.default)(msg).start();
|
|
49
|
+
let res;
|
|
50
|
+
try {
|
|
51
|
+
res = await fn();
|
|
52
|
+
spinner.succeed();
|
|
53
|
+
return res;
|
|
54
|
+
}
|
|
55
|
+
catch (err) {
|
|
56
|
+
spinner.fail();
|
|
57
|
+
throw err;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
exports.spinWith = spinWith;
|
|
61
|
+
class RingBuffer {
|
|
62
|
+
constructor(size = 50) {
|
|
63
|
+
this.size = size;
|
|
64
|
+
this.buffer = [];
|
|
65
|
+
}
|
|
66
|
+
getBuff() {
|
|
67
|
+
return this.buffer;
|
|
68
|
+
}
|
|
69
|
+
dequeue() {
|
|
70
|
+
this.buffer.shift();
|
|
71
|
+
}
|
|
72
|
+
enqueue(item) {
|
|
73
|
+
if (this.buffer.length >= this.size) {
|
|
74
|
+
this.dequeue();
|
|
75
|
+
}
|
|
76
|
+
this.buffer.push(item);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
exports.RingBuffer = RingBuffer;
|
|
80
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../lib/cli/utils.js"],"names":[],"mappings":";AAAA,+BAA+B;;;;;;AAE/B,8CAAsB;AAEtB,MAAM,WAAW,GAAG,CAAC,CAAC;AAqEa,kCAAW;AAnE9C;;;;GAIG;AACH,SAAS,UAAU,CAAC,IAAI,EAAE,GAAG;IAC3B,IAAI,IAAI,EAAE;QACR,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,EAAC,KAAK,EAAE,GAAG,GAAG,EAAE,EAAC,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC,CAAC;KACnE;SAAM;QACL,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,GAAG,CAAC,MAAM,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC;SACpC;KACF;IACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC;AAoDO,gCAAU;AAlDlB;;;;GAIG;AACH,SAAS,GAAG,CAAC,IAAI,EAAE,GAAG;IACpB,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;AA2CmB,kBAAG;AAzCvB;;;;;GAKG;AACH,KAAK,UAAU,QAAQ,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;IACnC,IAAI,IAAI,EAAE;QACR,OAAO,MAAM,EAAE,EAAE,CAAC;KACnB;IACD,MAAM,OAAO,GAAG,IAAA,aAAG,EAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC;IACjC,IAAI,GAAG,CAAC;IACR,IAAI;QACF,GAAG,GAAG,MAAM,EAAE,EAAE,CAAC;QACjB,OAAO,CAAC,OAAO,EAAE,CAAC;QAClB,OAAO,GAAG,CAAC;KACZ;IAAC,OAAO,GAAG,EAAE;QACZ,OAAO,CAAC,IAAI,EAAE,CAAC;QACf,MAAM,GAAG,CAAC;KACX;AACH,CAAC;AAqBwB,4BAAQ;AAnBjC,MAAM,UAAU;IACd,YAAY,IAAI,GAAG,EAAE;QACnB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;IACnB,CAAC;IACD,OAAO;QACL,OAAO,IAAI,CAAC,MAAM,CAAC;IACrB,CAAC;IACD,OAAO;QACL,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;IACtB,CAAC;IACD,OAAO,CAAC,IAAI;QACV,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,EAAE;YACnC,IAAI,CAAC,OAAO,EAAE,CAAC;SAChB;QACD,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACzB,CAAC;CACF;AAE+C,gCAAU"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Given an array of errors and the result of loading a config file, generate a
|
|
3
|
+
* helpful string for the user.
|
|
4
|
+
*
|
|
5
|
+
* - If `opts` contains a `json` property, this should be the original JSON
|
|
6
|
+
* _string_ of the config file. This is only applicable if the config file
|
|
7
|
+
* was in JSON format. If present, it will associate line numbers with errors.
|
|
8
|
+
* - If `errors` happens to be empty, this will throw.
|
|
9
|
+
* @param {import('ajv').ErrorObject[]} errors - Non-empty array of errors. Required.
|
|
10
|
+
* @param {ReadConfigFileResult['config']|any} [config] -
|
|
11
|
+
* Configuration & metadata
|
|
12
|
+
* @param {FormatConfigErrorsOptions} [opts]
|
|
13
|
+
* @throws {TypeError} If `errors` is empty
|
|
14
|
+
* @returns {string}
|
|
15
|
+
*/
|
|
16
|
+
export function formatErrors(errors?: import('ajv').ErrorObject[], config?: ReadConfigFileResult['config'] | any, opts?: FormatConfigErrorsOptions | undefined): string;
|
|
17
|
+
/**
|
|
18
|
+
* Given an optional path, read a config file. Validates the config file.
|
|
19
|
+
*
|
|
20
|
+
* Call {@link validate} if you already have a config object.
|
|
21
|
+
* @param {string} [filepath] - Path to config file, if we have one
|
|
22
|
+
* @param {ReadConfigFileOptions} [opts] - Options
|
|
23
|
+
* @public
|
|
24
|
+
* @returns {Promise<ReadConfigFileResult>} Contains config and filepath, if found, and any errors
|
|
25
|
+
*/
|
|
26
|
+
export function readConfigFile(filepath?: string | undefined, opts?: ReadConfigFileOptions | undefined): Promise<ReadConfigFileResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Convert schema property names to either a) the value of the `appiumCliDest` property, if any; or b) camel-case
|
|
29
|
+
* @param {AppiumConfig} config - Configuration object
|
|
30
|
+
* @returns {NormalizedAppiumConfig} New object with camel-cased keys (or `dest` keys).
|
|
31
|
+
*/
|
|
32
|
+
export function normalizeConfig(config: AppiumConfig): NormalizedAppiumConfig;
|
|
33
|
+
/**
|
|
34
|
+
* Result of calling {@link readConfigFile }.
|
|
35
|
+
*/
|
|
36
|
+
export type ReadConfigFileResult = {
|
|
37
|
+
/**
|
|
38
|
+
* - Validation errors
|
|
39
|
+
*/
|
|
40
|
+
errors?: import("ajv").ErrorObject<string, Record<string, any>, any>[] | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* - The path to the config file, if found
|
|
43
|
+
*/
|
|
44
|
+
filepath?: string | undefined;
|
|
45
|
+
/**
|
|
46
|
+
* - If `true`, the config file exists but is empty
|
|
47
|
+
*/
|
|
48
|
+
isEmpty?: boolean | undefined;
|
|
49
|
+
/**
|
|
50
|
+
* - The parsed configuration
|
|
51
|
+
*/
|
|
52
|
+
config?: import("@appium/types").NormalizedAppiumConfig | undefined;
|
|
53
|
+
/**
|
|
54
|
+
* - Human-readable error messages and suggestions. If the `pretty` option is `true`, this will be a nice string to print.
|
|
55
|
+
*/
|
|
56
|
+
reason?: string | import("@sidvind/better-ajv-errors").IOutputError[] | undefined;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Options for {@link readConfigFile }.
|
|
60
|
+
*/
|
|
61
|
+
export type ReadConfigFileOptions = {
|
|
62
|
+
/**
|
|
63
|
+
* If `false`, do not use color and fancy formatting in the `reason` property of the {@link ReadConfigFileResult }. The value of `reason` is then suitable for machine-reading.
|
|
64
|
+
*/
|
|
65
|
+
pretty?: boolean | undefined;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* This is an `AsyncSearcher` which is inexplicably _not_ exported by the `lilconfig` type definition.
|
|
69
|
+
*/
|
|
70
|
+
export type LilconfigAsyncSearcher = ReturnType<typeof import("lilconfig")["lilconfig"]>;
|
|
71
|
+
/**
|
|
72
|
+
* The contents of an Appium config file. Generated from schema
|
|
73
|
+
*/
|
|
74
|
+
export type AppiumConfig = import('@appium/types').AppiumConfig;
|
|
75
|
+
/**
|
|
76
|
+
* The contents of an Appium config file with camelcased property names (and using `appiumCliDest` value if present). Generated from {@link AppiumConfig }
|
|
77
|
+
*/
|
|
78
|
+
export type NormalizedAppiumConfig = import('@appium/types').NormalizedAppiumConfig;
|
|
79
|
+
/**
|
|
80
|
+
* The string should be a raw JSON string.
|
|
81
|
+
*/
|
|
82
|
+
export type RawJson = string;
|
|
83
|
+
/**
|
|
84
|
+
* Options for {@link formatErrors }.
|
|
85
|
+
*/
|
|
86
|
+
export type FormatConfigErrorsOptions = {
|
|
87
|
+
/**
|
|
88
|
+
* - Raw JSON config (as string)
|
|
89
|
+
*/
|
|
90
|
+
json?: string | undefined;
|
|
91
|
+
/**
|
|
92
|
+
* - Whether to format errors as a CLI-friendly string
|
|
93
|
+
*/
|
|
94
|
+
pretty?: boolean | undefined;
|
|
95
|
+
/**
|
|
96
|
+
* - Specific ID of a prop; otherwise entire schema
|
|
97
|
+
*/
|
|
98
|
+
schemaId?: string | undefined;
|
|
99
|
+
};
|
|
100
|
+
//# sourceMappingURL=config-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config-file.d.ts","sourceRoot":"","sources":["../../lib/config-file.js"],"names":[],"mappings":"AAkEA;;;;;;;;;;;;;;GAcG;AACH,sCAPW,OAAO,KAAK,EAAE,WAAW,EAAE,WAC3B,oBAAoB,CAAC,QAAQ,CAAC,GAAC,GAAG,iDAIhC,MAAM,CAUlB;AAED;;;;;;;;GAQG;AACH,yGAFa,QAAQ,oBAAoB,CAAC,CAwCzC;AAED;;;;GAIG;AACH,wCAHW,YAAY,GACV,sBAAsB,CAgClC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qCAoBY,WAAW,2BAAoB,WAAW,CAAC,CAAC;;;;2BAK5C,OAAO,eAAe,EAAE,YAAY;;;;qCAKpC,OAAO,eAAe,EAAE,sBAAsB;;;;sBAK9C,MAAM"}
|