appium 3.2.1 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/lib/cli/args.d.ts +16 -12
- package/build/lib/cli/args.d.ts.map +1 -1
- package/build/lib/cli/args.js +15 -35
- package/build/lib/cli/args.js.map +1 -1
- package/build/lib/cli/driver-command.d.ts +51 -93
- package/build/lib/cli/driver-command.d.ts.map +1 -1
- package/build/lib/cli/driver-command.js +11 -66
- package/build/lib/cli/driver-command.js.map +1 -1
- package/build/lib/cli/extension-command.d.ts +211 -415
- package/build/lib/cli/extension-command.d.ts.map +1 -1
- package/build/lib/cli/extension-command.js +384 -653
- package/build/lib/cli/extension-command.js.map +1 -1
- package/build/lib/cli/extension.d.ts +11 -16
- package/build/lib/cli/extension.d.ts.map +1 -1
- package/build/lib/cli/extension.js +10 -28
- package/build/lib/cli/extension.js.map +1 -1
- package/build/lib/cli/parser.d.ts +40 -69
- package/build/lib/cli/parser.d.ts.map +1 -1
- package/build/lib/cli/parser.js +24 -59
- package/build/lib/cli/parser.js.map +1 -1
- package/build/lib/cli/plugin-command.d.ts +50 -90
- package/build/lib/cli/plugin-command.d.ts.map +1 -1
- package/build/lib/cli/plugin-command.js +11 -63
- package/build/lib/cli/plugin-command.js.map +1 -1
- package/build/lib/cli/setup-command.d.ts +21 -26
- package/build/lib/cli/setup-command.d.ts.map +1 -1
- package/build/lib/cli/setup-command.js +13 -55
- package/build/lib/cli/setup-command.js.map +1 -1
- package/build/lib/cli/utils.d.ts +27 -29
- package/build/lib/cli/utils.d.ts.map +1 -1
- package/build/lib/cli/utils.js +29 -31
- package/build/lib/cli/utils.js.map +1 -1
- package/build/lib/config-file.d.ts +24 -67
- package/build/lib/config-file.d.ts.map +1 -1
- package/build/lib/config-file.js +56 -115
- package/build/lib/config-file.js.map +1 -1
- package/build/lib/config.d.ts +42 -44
- package/build/lib/config.d.ts.map +1 -1
- package/build/lib/config.js +75 -107
- package/build/lib/config.js.map +1 -1
- package/build/lib/constants.d.ts +23 -23
- package/build/lib/constants.d.ts.map +1 -1
- package/build/lib/constants.js +10 -15
- package/build/lib/constants.js.map +1 -1
- package/build/lib/doctor/doctor.d.ts +40 -57
- package/build/lib/doctor/doctor.d.ts.map +1 -1
- package/build/lib/doctor/doctor.js +29 -60
- package/build/lib/doctor/doctor.js.map +1 -1
- package/build/lib/grid-register.d.ts +32 -7
- package/build/lib/grid-register.d.ts.map +1 -1
- package/build/lib/grid-register.js +84 -48
- package/build/lib/grid-register.js.map +1 -1
- package/build/lib/logsink.d.ts +13 -22
- package/build/lib/logsink.d.ts.map +1 -1
- package/build/lib/logsink.js +48 -103
- package/build/lib/logsink.js.map +1 -1
- package/build/lib/main.js +1 -1
- package/build/lib/main.js.map +1 -1
- package/build/lib/schema/arg-spec.d.ts +32 -107
- package/build/lib/schema/arg-spec.d.ts.map +1 -1
- package/build/lib/schema/arg-spec.js +11 -107
- package/build/lib/schema/arg-spec.js.map +1 -1
- package/build/lib/schema/cli-args.d.ts +3 -15
- package/build/lib/schema/cli-args.d.ts.map +1 -1
- package/build/lib/schema/cli-args.js +15 -105
- package/build/lib/schema/cli-args.js.map +1 -1
- package/build/lib/schema/cli-transformers.d.ts +15 -12
- package/build/lib/schema/cli-transformers.d.ts.map +1 -1
- package/build/lib/schema/cli-transformers.js +15 -45
- package/build/lib/schema/cli-transformers.js.map +1 -1
- package/build/lib/schema/index.d.ts +2 -2
- package/build/lib/schema/index.d.ts.map +1 -1
- package/build/lib/schema/index.js.map +1 -1
- package/build/lib/schema/keywords.d.ts +12 -20
- package/build/lib/schema/keywords.d.ts.map +1 -1
- package/build/lib/schema/keywords.js +6 -51
- package/build/lib/schema/keywords.js.map +1 -1
- package/build/lib/schema/schema.d.ts +106 -231
- package/build/lib/schema/schema.d.ts.map +1 -1
- package/build/lib/schema/schema.js +75 -345
- package/build/lib/schema/schema.js.map +1 -1
- package/build/lib/utils.d.ts +59 -238
- package/build/lib/utils.d.ts.map +1 -1
- package/build/lib/utils.js +55 -207
- package/build/lib/utils.js.map +1 -1
- package/lib/cli/{args.js → args.ts} +40 -51
- package/lib/cli/driver-command.ts +122 -0
- package/lib/cli/{extension-command.js → extension-command.ts} +610 -689
- package/lib/cli/extension.ts +65 -0
- package/lib/cli/{parser.js → parser.ts} +48 -71
- package/lib/cli/plugin-command.ts +117 -0
- package/lib/cli/{setup-command.js → setup-command.ts} +57 -72
- package/lib/cli/utils.ts +97 -0
- package/lib/config-file.ts +212 -0
- package/lib/{config.js → config.ts} +129 -141
- package/lib/{constants.js → constants.ts} +30 -41
- package/lib/doctor/{doctor.js → doctor.ts} +81 -91
- package/lib/grid-register.ts +250 -0
- package/lib/{logsink.js → logsink.ts} +91 -137
- package/lib/main.js +1 -1
- package/lib/schema/arg-spec.ts +131 -0
- package/lib/schema/cli-args.ts +171 -0
- package/lib/schema/cli-transformers.ts +83 -0
- package/lib/schema/keywords.ts +96 -0
- package/lib/schema/schema.ts +449 -0
- package/lib/utils.ts +404 -0
- package/package.json +19 -20
- package/tsconfig.json +1 -1
- package/build/package.json +0 -99
- package/lib/cli/driver-command.js +0 -174
- package/lib/cli/extension.js +0 -74
- package/lib/cli/plugin-command.js +0 -164
- package/lib/cli/utils.js +0 -91
- package/lib/config-file.js +0 -228
- package/lib/grid-register.js +0 -146
- package/lib/schema/arg-spec.js +0 -229
- package/lib/schema/cli-args.js +0 -254
- package/lib/schema/cli-transformers.js +0 -113
- package/lib/schema/keywords.js +0 -136
- package/lib/schema/schema.js +0 -725
- package/lib/utils.js +0 -512
- /package/lib/schema/{index.js → index.ts} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../lib/constants.
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../lib/constants.ts"],"names":[],"mappings":";;;;;;AAAA,0DAA6B;AAE7B;;GAEG;AACU,QAAA,WAAW,GAAG,QAAQ,CAAC;AAEpC;;GAEG;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0B,GAAG,mBAAI,CAAC,IAAI,CAAC,+BAAuB,EAAE,cAAc,CAAC,CAAC;AAEhF,QAAA,mBAAmB,GAAG,MAAM,CAAC;AAC7B,QAAA,sBAAsB,GAAG,SAAS,CAAC;AACnC,QAAA,wBAAwB,GAAG,WAAW,CAAC;AACvC,QAAA,qBAAqB,GAAG,QAAQ,CAAC;AACjC,QAAA,kBAAkB,GAAG,KAAK,CAAC;AAC3B,QAAA,qBAAqB,GAAG,QAAQ,CAAC;AAE9C;;GAEG;AACU,QAAA,kBAAkB,GAAG,CAAC,CAAC;AAEpC;;;;;GAKG;AACU,QAAA,qBAAqB,GAAG,GAAG,CAAC;AAEzC;;GAEG;AACU,QAAA,cAAc,GAAG,OAAO,CAAC;AAEtC;;;GAGG;AACU,QAAA,eAAe,GAAG,WAAW,CAAC;AAE3C;;GAEG;AACU,QAAA,yBAAyB,GAAG,mBAAmB,CAAC"}
|
|
@@ -1,65 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import '@colors/colors';
|
|
2
|
+
import type { IDoctorCheck } from '@appium/types';
|
|
3
|
+
/**
|
|
4
|
+
* Process exit codes returned by {@link Doctor.run}.
|
|
5
|
+
*/
|
|
6
|
+
export declare const EXIT_CODE: Readonly<{
|
|
7
|
+
readonly SUCCESS: 0;
|
|
8
|
+
readonly HAS_MAJOR_ISSUES: 127;
|
|
4
9
|
}>;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
/**
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
/** Exit code values produced by {@link Doctor.run}. */
|
|
11
|
+
export type DoctorExitCode = (typeof EXIT_CODE)[keyof typeof EXIT_CODE];
|
|
12
|
+
/**
|
|
13
|
+
* A failed check reported during {@link Doctor} diagnostics.
|
|
14
|
+
*/
|
|
15
|
+
export interface DoctorIssue {
|
|
16
|
+
/** The check that produced this issue. */
|
|
17
|
+
check: IDoctorCheck;
|
|
18
|
+
/** Colored message string as logged during diagnosis. */
|
|
19
|
+
error: string;
|
|
20
|
+
/** Set after a successful automatic fix attempt. */
|
|
21
|
+
fixed?: boolean;
|
|
22
|
+
}
|
|
23
|
+
export declare class Doctor {
|
|
24
|
+
private readonly log;
|
|
25
|
+
private readonly checks;
|
|
26
|
+
private foundIssues;
|
|
27
|
+
constructor(checks?: IDoctorCheck[]);
|
|
19
28
|
/**
|
|
20
|
-
*
|
|
29
|
+
* Runs diagnostics, reports issues, attempts automatic fixes where supported, and returns an exit code.
|
|
30
|
+
*
|
|
31
|
+
* @returns {@link EXIT_CODE.SUCCESS} when there are no issues or all issues were resolved;
|
|
32
|
+
* {@link EXIT_CODE.HAS_MAJOR_ISSUES} when manual intervention is still required or fixes failed.
|
|
21
33
|
*/
|
|
22
|
-
|
|
34
|
+
run(): Promise<DoctorExitCode>;
|
|
35
|
+
private get issuesRequiredToFix();
|
|
36
|
+
private get issuesOptionalToFix();
|
|
23
37
|
/**
|
|
24
38
|
* The doctor shows the report
|
|
25
39
|
*/
|
|
26
|
-
diagnose
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
*/
|
|
34
|
-
runAutoFix(f: DoctorIssue): Promise<void>;
|
|
35
|
-
/**
|
|
36
|
-
* @returns {Promise<boolean>}
|
|
37
|
-
*/
|
|
38
|
-
runAutoFixes(): Promise<boolean>;
|
|
39
|
-
/**
|
|
40
|
-
* @returns {Promise<EXIT_CODE[keyof EXIT_CODE]>}
|
|
41
|
-
*/
|
|
42
|
-
run(): Promise<0 | 127>;
|
|
43
|
-
/**
|
|
44
|
-
* @param {DoctorCheckResult} result
|
|
45
|
-
* @param {DoctorCheck} check
|
|
46
|
-
* @returns {DoctorIssue?}
|
|
47
|
-
*/
|
|
48
|
-
toIssue(result: DoctorCheckResult, check: DoctorCheck): DoctorIssue | null;
|
|
49
|
-
/**
|
|
50
|
-
* @returns {string}
|
|
51
|
-
*/
|
|
52
|
-
buildFixMessage(): string;
|
|
53
|
-
/**
|
|
54
|
-
* @returns {boolean}
|
|
55
|
-
*/
|
|
56
|
-
reportSuccess(): boolean;
|
|
40
|
+
private diagnose;
|
|
41
|
+
private reportManualIssues;
|
|
42
|
+
private runAutoFix;
|
|
43
|
+
private runAutoFixes;
|
|
44
|
+
private toIssue;
|
|
45
|
+
private buildFixMessage;
|
|
46
|
+
private reportSuccess;
|
|
57
47
|
}
|
|
58
|
-
export type DoctorIssue = {
|
|
59
|
-
check: DoctorCheck;
|
|
60
|
-
error: string;
|
|
61
|
-
fixed?: boolean | undefined;
|
|
62
|
-
};
|
|
63
|
-
export type DoctorCheck = import("@appium/types").IDoctorCheck;
|
|
64
|
-
export type DoctorCheckResult = import("@appium/types").DoctorCheckResult;
|
|
65
48
|
//# sourceMappingURL=doctor.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../../lib/doctor/doctor.
|
|
1
|
+
{"version":3,"file":"doctor.d.ts","sourceRoot":"","sources":["../../../lib/doctor/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAkC,YAAY,EAAC,MAAM,eAAe,CAAC;AAEjF;;GAEG;AACH,eAAO,MAAM,SAAS;;;EAGX,CAAC;AAEZ,uDAAuD;AACvD,MAAM,MAAM,cAAc,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAExE;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,0CAA0C;IAC1C,KAAK,EAAE,YAAY,CAAC;IACpB,yDAAyD;IACzD,KAAK,EAAE,MAAM,CAAC;IACd,oDAAoD;IACpD,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB;AAED,qBAAa,MAAM;IACjB,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAe;IACnC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAiB;IACxC,OAAO,CAAC,WAAW,CAAgB;gBAEvB,MAAM,GAAE,YAAY,EAAO;IAWvC;;;;;OAKG;IACG,GAAG,IAAI,OAAO,CAAC,cAAc,CAAC;IAcpC,OAAO,KAAK,mBAAmB,GAE9B;IAED,OAAO,KAAK,mBAAmB,GAE9B;IAED;;OAEG;YACW,QAAQ;YAcR,kBAAkB;YAuDlB,UAAU;YA0BV,YAAY;IAkB1B,OAAO,CAAC,OAAO;IAgBf,OAAO,CAAC,eAAe;IAOvB,OAAO,CAAC,aAAa;CAQtB"}
|
|
@@ -7,33 +7,49 @@ exports.Doctor = exports.EXIT_CODE = void 0;
|
|
|
7
7
|
require("@colors/colors");
|
|
8
8
|
const lodash_1 = __importDefault(require("lodash"));
|
|
9
9
|
const support_1 = require("@appium/support");
|
|
10
|
+
/**
|
|
11
|
+
* Process exit codes returned by {@link Doctor.run}.
|
|
12
|
+
*/
|
|
10
13
|
exports.EXIT_CODE = Object.freeze({
|
|
11
14
|
SUCCESS: 0,
|
|
12
15
|
HAS_MAJOR_ISSUES: 127,
|
|
13
16
|
});
|
|
14
17
|
class Doctor {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
+
log;
|
|
19
|
+
checks;
|
|
20
|
+
foundIssues;
|
|
18
21
|
constructor(checks = []) {
|
|
19
22
|
this.log = support_1.logger.getLogger('Doctor');
|
|
20
|
-
/** @type {DoctorCheck[]} */
|
|
21
23
|
this.checks = checks;
|
|
22
24
|
this.checks
|
|
23
25
|
.filter((c) => lodash_1.default.isNil(c.log))
|
|
24
|
-
.forEach((c) => {
|
|
25
|
-
|
|
26
|
+
.forEach((c) => {
|
|
27
|
+
c.log = this.log;
|
|
28
|
+
});
|
|
26
29
|
this.foundIssues = [];
|
|
27
30
|
}
|
|
28
31
|
/**
|
|
29
|
-
*
|
|
32
|
+
* Runs diagnostics, reports issues, attempts automatic fixes where supported, and returns an exit code.
|
|
33
|
+
*
|
|
34
|
+
* @returns {@link EXIT_CODE.SUCCESS} when there are no issues or all issues were resolved;
|
|
35
|
+
* {@link EXIT_CODE.HAS_MAJOR_ISSUES} when manual intervention is still required or fixes failed.
|
|
30
36
|
*/
|
|
37
|
+
async run() {
|
|
38
|
+
await this.diagnose();
|
|
39
|
+
if (this.reportSuccess()) {
|
|
40
|
+
return exports.EXIT_CODE.SUCCESS;
|
|
41
|
+
}
|
|
42
|
+
if (await this.reportManualIssues()) {
|
|
43
|
+
return exports.EXIT_CODE.HAS_MAJOR_ISSUES;
|
|
44
|
+
}
|
|
45
|
+
if (!(await this.runAutoFixes())) {
|
|
46
|
+
return exports.EXIT_CODE.HAS_MAJOR_ISSUES;
|
|
47
|
+
}
|
|
48
|
+
return exports.EXIT_CODE.SUCCESS;
|
|
49
|
+
}
|
|
31
50
|
get issuesRequiredToFix() {
|
|
32
51
|
return this.foundIssues.filter((f) => !f.check.isOptional());
|
|
33
52
|
}
|
|
34
|
-
/**
|
|
35
|
-
* @returns {DoctorIssue[]}
|
|
36
|
-
*/
|
|
37
53
|
get issuesOptionalToFix() {
|
|
38
54
|
return this.foundIssues.filter((f) => f.check.isOptional());
|
|
39
55
|
}
|
|
@@ -53,9 +69,6 @@ class Doctor {
|
|
|
53
69
|
this.log.info(`### Diagnostic completed, ${this.buildFixMessage()}. ###`);
|
|
54
70
|
this.log.info('');
|
|
55
71
|
}
|
|
56
|
-
/**
|
|
57
|
-
* @returns {Promise<boolean>}
|
|
58
|
-
*/
|
|
59
72
|
async reportManualIssues() {
|
|
60
73
|
const manualIssues = lodash_1.default.filter(this.issuesRequiredToFix, (f) => !f.check.hasAutofix());
|
|
61
74
|
const manualIssuesOptional = lodash_1.default.filter(this.issuesOptionalToFix, (f) => !f.check.hasAutofix());
|
|
@@ -66,7 +79,6 @@ class Doctor {
|
|
|
66
79
|
for (const logMsg of headerLogs) {
|
|
67
80
|
this.log.info(logMsg);
|
|
68
81
|
}
|
|
69
|
-
/** @type {string[]} */
|
|
70
82
|
const fixMessages = [];
|
|
71
83
|
for (const issue of issues) {
|
|
72
84
|
let message;
|
|
@@ -102,16 +114,13 @@ class Doctor {
|
|
|
102
114
|
}
|
|
103
115
|
return false;
|
|
104
116
|
}
|
|
105
|
-
/**
|
|
106
|
-
* @param {DoctorIssue} f
|
|
107
|
-
*/
|
|
108
117
|
async runAutoFix(f) {
|
|
109
118
|
this.log.info(`### Fixing: ${f.error} ###`);
|
|
110
119
|
try {
|
|
111
120
|
await f.check.fix();
|
|
112
121
|
}
|
|
113
122
|
catch (err) {
|
|
114
|
-
if (err
|
|
123
|
+
if (err instanceof support_1.doctor.FixSkippedError) {
|
|
115
124
|
this.log.info(`### Skipped fix ###`);
|
|
116
125
|
return;
|
|
117
126
|
}
|
|
@@ -133,9 +142,6 @@ class Doctor {
|
|
|
133
142
|
this.log.info(`### Fix was applied but issue remains ###`);
|
|
134
143
|
}
|
|
135
144
|
}
|
|
136
|
-
/**
|
|
137
|
-
* @returns {Promise<boolean>}
|
|
138
|
-
*/
|
|
139
145
|
async runAutoFixes() {
|
|
140
146
|
const autoFixes = lodash_1.default.filter(this.foundIssues, (f) => f.check.hasAutofix());
|
|
141
147
|
for (const f of autoFixes) {
|
|
@@ -153,27 +159,6 @@ class Doctor {
|
|
|
153
159
|
this.log.info('');
|
|
154
160
|
return true;
|
|
155
161
|
}
|
|
156
|
-
/**
|
|
157
|
-
* @returns {Promise<EXIT_CODE[keyof EXIT_CODE]>}
|
|
158
|
-
*/
|
|
159
|
-
async run() {
|
|
160
|
-
await this.diagnose();
|
|
161
|
-
if (this.reportSuccess()) {
|
|
162
|
-
return exports.EXIT_CODE.SUCCESS;
|
|
163
|
-
}
|
|
164
|
-
if (await this.reportManualIssues()) {
|
|
165
|
-
return exports.EXIT_CODE.HAS_MAJOR_ISSUES;
|
|
166
|
-
}
|
|
167
|
-
if (!await this.runAutoFixes()) {
|
|
168
|
-
return exports.EXIT_CODE.HAS_MAJOR_ISSUES;
|
|
169
|
-
}
|
|
170
|
-
return exports.EXIT_CODE.SUCCESS;
|
|
171
|
-
}
|
|
172
|
-
/**
|
|
173
|
-
* @param {DoctorCheckResult} result
|
|
174
|
-
* @param {DoctorCheck} check
|
|
175
|
-
* @returns {DoctorIssue?}
|
|
176
|
-
*/
|
|
177
162
|
toIssue(result, check) {
|
|
178
163
|
if (result.ok) {
|
|
179
164
|
this.log.info(` ${'\u2714'.green} ${result.message}`);
|
|
@@ -188,16 +173,10 @@ class Doctor {
|
|
|
188
173
|
check,
|
|
189
174
|
};
|
|
190
175
|
}
|
|
191
|
-
/**
|
|
192
|
-
* @returns {string}
|
|
193
|
-
*/
|
|
194
176
|
buildFixMessage() {
|
|
195
|
-
return `${support_1.util.pluralize('required fix', this.issuesRequiredToFix.length, true)} needed, ` +
|
|
196
|
-
`${support_1.util.pluralize('optional fix', this.issuesOptionalToFix.length, true)} possible
|
|
177
|
+
return (`${support_1.util.pluralize('required fix', this.issuesRequiredToFix.length, true)} needed, ` +
|
|
178
|
+
`${support_1.util.pluralize('optional fix', this.issuesOptionalToFix.length, true)} possible`);
|
|
197
179
|
}
|
|
198
|
-
/**
|
|
199
|
-
* @returns {boolean}
|
|
200
|
-
*/
|
|
201
180
|
reportSuccess() {
|
|
202
181
|
if (this.issuesRequiredToFix.length === 0 && this.issuesOptionalToFix.length === 0) {
|
|
203
182
|
this.log.info('Everything looks good, bye!');
|
|
@@ -208,14 +187,4 @@ class Doctor {
|
|
|
208
187
|
}
|
|
209
188
|
}
|
|
210
189
|
exports.Doctor = Doctor;
|
|
211
|
-
/**
|
|
212
|
-
* @typedef DoctorIssue
|
|
213
|
-
* @property {DoctorCheck} check
|
|
214
|
-
* @property {string} error
|
|
215
|
-
* @property {boolean} [fixed]
|
|
216
|
-
*/
|
|
217
|
-
/**
|
|
218
|
-
* @typedef {import('@appium/types').IDoctorCheck} DoctorCheck
|
|
219
|
-
* @typedef {import('@appium/types').DoctorCheckResult} DoctorCheckResult
|
|
220
|
-
*/
|
|
221
190
|
//# sourceMappingURL=doctor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../../lib/doctor/doctor.
|
|
1
|
+
{"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../../lib/doctor/doctor.ts"],"names":[],"mappings":";;;;;;AAAA,0BAAwB;AACxB,oDAAuB;AACvB,6CAAqD;AAGrD;;GAEG;AACU,QAAA,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;IACrC,OAAO,EAAE,CAAC;IACV,gBAAgB,EAAE,GAAG;CACb,CAAC,CAAC;AAiBZ,MAAa,MAAM;IACA,GAAG,CAAe;IAClB,MAAM,CAAiB;IAChC,WAAW,CAAgB;IAEnC,YAAY,SAAyB,EAAE;QACrC,IAAI,CAAC,GAAG,GAAG,gBAAM,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;QACtC,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,MAAM;aACR,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,gBAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;aAC7B,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACb,CAAC,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;QACnB,CAAC,CAAC,CAAC;QACL,IAAI,CAAC,WAAW,GAAG,EAAE,CAAC;IACxB,CAAC;IAED;;;;;OAKG;IACH,KAAK,CAAC,GAAG;QACP,MAAM,IAAI,CAAC,QAAQ,EAAE,CAAC;QACtB,IAAI,IAAI,CAAC,aAAa,EAAE,EAAE,CAAC;YACzB,OAAO,iBAAS,CAAC,OAAO,CAAC;QAC3B,CAAC;QACD,IAAI,MAAM,IAAI,CAAC,kBAAkB,EAAE,EAAE,CAAC;YACpC,OAAO,iBAAS,CAAC,gBAAgB,CAAC;QACpC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
import type { StringRecord } from '@appium/types';
|
|
2
2
|
/**
|
|
3
|
-
* Registers a
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
3
|
+
* Registers this server as a node with a **Selenium Grid 3** hub.
|
|
4
|
+
*
|
|
5
|
+
* When `data` is a path to a JSON config file, `addr`, `port`, and `basePath` are required (they define
|
|
6
|
+
* how the hub reaches this Appium server). When `data` is an inline config object, those parameters are
|
|
7
|
+
* optional and only used to fill missing node URL fields in the config.
|
|
8
|
+
*
|
|
9
|
+
* @deprecated Selenium Grid 3 registration is legacy and slated for removal.
|
|
10
|
+
* Use Selenium Grid 4 integration (node relay) instead.
|
|
11
|
+
*
|
|
12
|
+
* @param data - Path to a JSON file or an inline parsed config object
|
|
13
|
+
* @param addr - Bind to this address
|
|
14
|
+
* @param port - Bind to this port
|
|
15
|
+
* @param basePath - Base path for the Appium server (used in the node URL sent to the hub; may be `''`)
|
|
8
16
|
*/
|
|
9
|
-
|
|
17
|
+
export default function registerNode(data: string, addr: string, port: number, basePath: string): Promise<void>;
|
|
18
|
+
export default function registerNode(data: Grid3NodeConfig, addr?: string, port?: number, basePath?: string): Promise<void>;
|
|
19
|
+
interface Grid3HubConfiguration {
|
|
20
|
+
hubProtocol?: string;
|
|
21
|
+
hubHost?: string;
|
|
22
|
+
hubPort?: number;
|
|
23
|
+
url?: string;
|
|
24
|
+
host?: string;
|
|
25
|
+
port?: number;
|
|
26
|
+
id?: string;
|
|
27
|
+
register?: boolean;
|
|
28
|
+
registerCycle?: number;
|
|
29
|
+
}
|
|
30
|
+
interface Grid3NodeConfig extends StringRecord {
|
|
31
|
+
configuration?: Grid3HubConfiguration;
|
|
32
|
+
capabilities?: unknown;
|
|
33
|
+
}
|
|
34
|
+
export {};
|
|
10
35
|
//# sourceMappingURL=grid-register.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid-register.d.ts","sourceRoot":"","sources":["../../lib/grid-register.
|
|
1
|
+
{"version":3,"file":"grid-register.d.ts","sourceRoot":"","sources":["../../lib/grid-register.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,eAAe,CAAC;AAkBhD;;;;;;;;;;;;;;GAcG;AACH,wBAA8B,YAAY,CACxC,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,IAAI,CAAC,CAAC;AACjB,wBAA8B,YAAY,CACxC,IAAI,EAAE,eAAe,EACrB,IAAI,CAAC,EAAE,MAAM,EACb,IAAI,CAAC,EAAE,MAAM,EACb,QAAQ,CAAC,EAAE,MAAM,GAChB,OAAO,CAAC,IAAI,CAAC,CAAC;AAuLjB,UAAU,qBAAqB;IAC7B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,eAAgB,SAAQ,YAAY;IAC5C,aAAa,CAAC,EAAE,qBAAqB,CAAC;IACtC,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB"}
|
|
@@ -3,100 +3,131 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.default = registerNode;
|
|
6
7
|
const axios_1 = __importDefault(require("axios"));
|
|
7
8
|
const support_1 = require("@appium/support");
|
|
8
|
-
const logger_1 = __importDefault(require("./logger"));
|
|
9
9
|
const lodash_1 = __importDefault(require("lodash"));
|
|
10
|
-
const
|
|
11
|
-
const protocol = config.hubProtocol || 'http';
|
|
12
|
-
return `${protocol}://${config.hubHost}:${config.hubPort}`;
|
|
13
|
-
};
|
|
10
|
+
const logger_1 = __importDefault(require("./logger"));
|
|
14
11
|
/**
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
12
|
+
* Selenium **Grid 3** (legacy hub) node integration.
|
|
13
|
+
*
|
|
14
|
+
* Registers this Appium process as a node with a Selenium Grid 3 hub using the classic
|
|
15
|
+
* `/grid/register` endpoint and `/grid/api/proxy` for re-registration checks.
|
|
16
|
+
* This does **not** apply to Selenium Grid 4 (which uses a different topology and APIs).
|
|
17
|
+
*
|
|
18
|
+
* @see https://www.selenium.dev/documentation/legacy/grid_3/
|
|
20
19
|
*/
|
|
20
|
+
/** REST paths exposed by a Selenium Grid 3 hub. */
|
|
21
|
+
const GRID_V3_REGISTER_PATH = '/grid/register';
|
|
22
|
+
const GRID_V3_PROXY_API_PATH = '/grid/api/proxy';
|
|
21
23
|
async function registerNode(data, addr, port, basePath) {
|
|
22
|
-
|
|
24
|
+
if (typeof data === 'string') {
|
|
25
|
+
if (addr === undefined || port === undefined || basePath === undefined) {
|
|
26
|
+
throw logger_1.default.errorWithException('When the first argument is a Selenium Grid 3 node config file path, address, port, and basePath ' +
|
|
27
|
+
'are required (e.g. match your Appium `--address`, `--port`, and base path).');
|
|
28
|
+
}
|
|
29
|
+
if (typeof port !== 'number' || !Number.isFinite(port)) {
|
|
30
|
+
throw logger_1.default.errorWithException('When registering from a node config file path, port must be a finite number.');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
let configHolder;
|
|
23
34
|
if (lodash_1.default.isString(data)) {
|
|
24
|
-
configFilePath = data;
|
|
35
|
+
const configFilePath = data;
|
|
36
|
+
let fileContent;
|
|
25
37
|
try {
|
|
26
|
-
|
|
38
|
+
fileContent = await support_1.fs.readFile(data, 'utf-8');
|
|
27
39
|
}
|
|
28
40
|
catch (err) {
|
|
29
|
-
logger_1.default.error(`Unable to load node configuration file ${configFilePath} to
|
|
41
|
+
logger_1.default.error(`Unable to load Selenium Grid 3 node configuration file ${configFilePath} to ` +
|
|
42
|
+
`register with the hub: ${err.message}`);
|
|
30
43
|
return;
|
|
31
44
|
}
|
|
32
45
|
try {
|
|
33
|
-
|
|
46
|
+
configHolder = JSON.parse(fileContent);
|
|
34
47
|
}
|
|
35
48
|
catch (err) {
|
|
36
|
-
throw logger_1.default.errorWithException(`Syntax error in node configuration file ${configFilePath}:
|
|
49
|
+
throw logger_1.default.errorWithException(`Syntax error in Selenium Grid 3 node configuration file ${configFilePath}: ` +
|
|
50
|
+
err.message);
|
|
37
51
|
}
|
|
38
52
|
}
|
|
39
|
-
|
|
53
|
+
else {
|
|
54
|
+
configHolder = data;
|
|
55
|
+
}
|
|
56
|
+
postRequest(configHolder, addr, port, basePath);
|
|
40
57
|
}
|
|
58
|
+
/** Base URL for the Selenium Grid 3 hub (protocol + host + port). */
|
|
59
|
+
function hubUri(config) {
|
|
60
|
+
const protocol = config.hubProtocol || 'http';
|
|
61
|
+
return `${protocol}://${config.hubHost}:${config.hubPort}`;
|
|
62
|
+
}
|
|
63
|
+
/** POST registration payload to the Selenium Grid 3 hub. */
|
|
41
64
|
async function registerToGrid(postOptions, configHolder) {
|
|
65
|
+
const hubCfg = configHolder.configuration;
|
|
66
|
+
if (!hubCfg) {
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
42
69
|
try {
|
|
43
70
|
const { status } = await (0, axios_1.default)(postOptions);
|
|
44
71
|
if (status !== 200) {
|
|
45
72
|
throw new Error(`Request failed with code ${status}`);
|
|
46
73
|
}
|
|
47
|
-
logger_1.default.debug(`Appium successfully registered with the
|
|
74
|
+
logger_1.default.debug(`Appium successfully registered with the Selenium Grid 3 hub at ` + hubUri(hubCfg));
|
|
48
75
|
}
|
|
49
76
|
catch (err) {
|
|
50
|
-
logger_1.default.error(`An attempt to register with the
|
|
77
|
+
logger_1.default.error(`An attempt to register with the Selenium Grid 3 hub was unsuccessful: ` +
|
|
78
|
+
err.message);
|
|
51
79
|
}
|
|
52
80
|
}
|
|
53
81
|
function postRequest(configHolder, addr, port, basePath) {
|
|
54
|
-
// Move Selenium 3 configuration properties
|
|
82
|
+
// Move Selenium Grid 3 (flat) configuration properties into `configuration`
|
|
55
83
|
if (!lodash_1.default.has(configHolder, 'configuration')) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
84
|
+
const configuration = {};
|
|
85
|
+
const holder = configHolder;
|
|
86
|
+
for (const property in holder) {
|
|
87
|
+
if (lodash_1.default.has(holder, property) && property !== 'capabilities') {
|
|
88
|
+
configuration[property] = holder[property];
|
|
89
|
+
delete holder[property];
|
|
61
90
|
}
|
|
62
91
|
}
|
|
63
|
-
|
|
92
|
+
holder.configuration = configuration;
|
|
93
|
+
}
|
|
94
|
+
const cfg = configHolder.configuration;
|
|
95
|
+
if (!cfg) {
|
|
96
|
+
return;
|
|
64
97
|
}
|
|
65
98
|
// if the node config does not have the appium/webdriver url, host, and port,
|
|
66
99
|
// automatically add it based on how appium was initialized
|
|
67
100
|
// otherwise, we will take whatever the user setup
|
|
68
101
|
// because we will always set localhost/127.0.0.1. this won't work if your
|
|
69
|
-
// node and
|
|
70
|
-
if (!
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
configHolder.configuration.host = addr;
|
|
75
|
-
configHolder.configuration.port = port;
|
|
102
|
+
// node and hub aren't in the same place
|
|
103
|
+
if (!cfg.url || !cfg.host || !cfg.port) {
|
|
104
|
+
cfg.url = `http://${addr}:${port}${basePath}`;
|
|
105
|
+
cfg.host = addr;
|
|
106
|
+
cfg.port = port;
|
|
76
107
|
}
|
|
77
108
|
// if the node config does not have id automatically add it
|
|
78
|
-
if (!
|
|
79
|
-
|
|
109
|
+
if (!cfg.id) {
|
|
110
|
+
cfg.id = `http://${cfg.host}:${cfg.port}`;
|
|
80
111
|
}
|
|
81
112
|
// the post options
|
|
82
113
|
const regRequest = {
|
|
83
|
-
url: `${hubUri(
|
|
114
|
+
url: `${hubUri(cfg)}${GRID_V3_REGISTER_PATH}`,
|
|
84
115
|
method: 'POST',
|
|
85
116
|
data: configHolder,
|
|
86
117
|
};
|
|
87
|
-
if (
|
|
88
|
-
logger_1.default.debug(`No registration sent (${
|
|
118
|
+
if (cfg.register !== true) {
|
|
119
|
+
logger_1.default.debug(`No Selenium Grid 3 hub registration sent (${cfg.register} = false)`);
|
|
89
120
|
return;
|
|
90
121
|
}
|
|
91
|
-
const registerCycleInterval =
|
|
92
|
-
if (isNaN(registerCycleInterval) || registerCycleInterval <= 0) {
|
|
122
|
+
const registerCycleInterval = cfg.registerCycle;
|
|
123
|
+
if (registerCycleInterval === undefined || isNaN(registerCycleInterval) || registerCycleInterval <= 0) {
|
|
93
124
|
logger_1.default.warn(`'registerCycle' is not a valid positive number. ` +
|
|
94
|
-
`No registration request will be sent to the
|
|
125
|
+
`No registration request will be sent to the Selenium Grid 3 hub.`);
|
|
95
126
|
return;
|
|
96
127
|
}
|
|
97
128
|
// initiate a new Thread
|
|
98
129
|
let first = true;
|
|
99
|
-
logger_1.default.debug(`Starting auto
|
|
130
|
+
logger_1.default.debug(`Starting auto-register thread for Selenium Grid 3. ` +
|
|
100
131
|
`Will try to register every ${registerCycleInterval} ms.`);
|
|
101
132
|
setInterval(async function registerRetry() {
|
|
102
133
|
if (first) {
|
|
@@ -104,17 +135,23 @@ function postRequest(configHolder, addr, port, basePath) {
|
|
|
104
135
|
await registerToGrid(regRequest, configHolder);
|
|
105
136
|
}
|
|
106
137
|
else if (!(await isAlreadyRegistered(configHolder))) {
|
|
107
|
-
// make the http POST to the
|
|
138
|
+
// make the http POST to the Selenium Grid 3 hub for registration
|
|
108
139
|
await registerToGrid(regRequest, configHolder);
|
|
109
140
|
}
|
|
110
141
|
}, registerCycleInterval);
|
|
111
142
|
}
|
|
143
|
+
/** Query the Selenium Grid 3 hub to see if this node id is already registered. */
|
|
112
144
|
async function isAlreadyRegistered(configHolder) {
|
|
113
145
|
//check if node is already registered
|
|
114
|
-
const
|
|
146
|
+
const hubCfg = configHolder.configuration;
|
|
147
|
+
if (!hubCfg?.id) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
const id = hubCfg.id;
|
|
115
151
|
try {
|
|
116
152
|
const { data, status } = await (0, axios_1.default)({
|
|
117
|
-
url: `${hubUri(
|
|
153
|
+
url: `${hubUri(hubCfg)}${GRID_V3_PROXY_API_PATH}`,
|
|
154
|
+
params: { id },
|
|
118
155
|
timeout: 10000,
|
|
119
156
|
});
|
|
120
157
|
if (status !== 200) {
|
|
@@ -122,13 +159,12 @@ async function isAlreadyRegistered(configHolder) {
|
|
|
122
159
|
}
|
|
123
160
|
if (!data.success) {
|
|
124
161
|
// if register fail, print the debug msg
|
|
125
|
-
logger_1.default.debug(`Grid registration
|
|
162
|
+
logger_1.default.debug(`Selenium Grid 3 hub registration check: ${data.msg}`);
|
|
126
163
|
}
|
|
127
164
|
return data.success;
|
|
128
165
|
}
|
|
129
166
|
catch (err) {
|
|
130
|
-
logger_1.default.debug(`
|
|
167
|
+
logger_1.default.debug(`Selenium Grid 3 hub down or not responding: ${err.message}`);
|
|
131
168
|
}
|
|
132
169
|
}
|
|
133
|
-
exports.default = registerNode;
|
|
134
170
|
//# sourceMappingURL=grid-register.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grid-register.js","sourceRoot":"","sources":["../../lib/grid-register.
|
|
1
|
+
{"version":3,"file":"grid-register.js","sourceRoot":"","sources":["../../lib/grid-register.ts"],"names":[],"mappings":";;;;;AA+CA,+BA8CC;AA7FD,kDAA0B;AAC1B,6CAAmC;AAEnC,oDAAuB;AACvB,sDAA8B;AAE9B;;;;;;;;GAQG;AAEH,mDAAmD;AACnD,MAAM,qBAAqB,GA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