Skip to content

Commit 1b04194

Browse files
committed
Revert "feat(max_versions): set max versions based on string matching (#369)"
This reverts commit c9a52b2.
1 parent e4a8bbe commit 1b04194

13 files changed

+134
-258
lines changed

lib/cli/index.ts

+38-99
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,14 @@ import * as start from '../cmds/start';
55
import * as status from '../cmds/status';
66
import * as update from '../cmds/update';
77

8-
const CHROMEDRIVER_ALIAS = 'chrome';
9-
const CHROMEDRIVER = 'chromedriver';
10-
const chromedriverOption: yargs.Options = {
8+
const CHROME = 'chrome';
9+
const chromeOption: yargs.Options = {
1110
describe: 'Install or update chromedriver.',
1211
default: true,
1312
type: 'boolean'
1413
};
15-
const CHROMEDRIVER_LOGS_ALIAS = 'chrome_logs';
16-
const CHROMEDRIVER_LOGS = 'chromedriver_logs';
17-
const chromedriverLogsOption: yargs.Options = {
14+
const CHROME_LOGS = 'chrome_logs';
15+
const chromeLogsOption: yargs.Options = {
1816
describe: 'File path to chrome logs.',
1917
type: 'string'
2018
};
@@ -32,9 +30,8 @@ const edgeOption: yargs.Options = {
3230
'"C:\Program Files (x86)\Microsoft Web Driver\MirosoftWebDriver.exe"',
3331
type: 'string'
3432
};
35-
const GECKODRIVER_ALIAS = 'gecko';
36-
const GECKODRIVER = 'geckodriver';
37-
const geckodriverOption: yargs.Options = {
33+
const GECKO = 'gecko';
34+
const geckoOption: yargs.Options = {
3835
describe: 'Install or update geckodriver.',
3936
default: true,
4037
type: 'boolean'
@@ -44,9 +41,8 @@ const githubTokenOption: yargs.Options = {
4441
describe: 'Use a GitHub token to prevent rate limit issues.',
4542
type: 'string'
4643
};
47-
const IEDRIVER_ALIAS = 'ie';
4844
const IEDRIVER = 'iedriver';
49-
const iedriverOption: yargs.Options = {
45+
const ieOption: yargs.Options = {
5046
describe: 'Install or update ie driver.',
5147
default: false,
5248
type: 'boolean'
@@ -62,31 +58,6 @@ const logLevelOption: yargs.Options = {
6258
default: 'info',
6359
type: 'string'
6460
};
65-
const MAX_VERSIONS_CHROMEDRIVER_ALIAS = 'max_versions.chrome';
66-
const MAX_VERSIONS_CHROMEDRIVER = 'max_versions.chromedriver';
67-
const maxVersionsChromedriverOption: yargs.Options = {
68-
describe: 'The chromedriver max version used only for update.',
69-
type: 'string'
70-
};
71-
const MAX_VERSIONS_GECKODRIVER_ALIAS = 'max_versions.gecko';
72-
const MAX_VERSIONS_GECKODRIVER = 'max_versions.geckodriver';
73-
const maxVersionsGeckodriverOption: yargs.Options = {
74-
describe: 'The geckodriver max version used only for update.',
75-
type: 'string'
76-
};
77-
const MAX_VERSIONS_IEDRIVER_ALIAS = 'max_versions.ie';
78-
const MAX_VERSIONS_IEDRIVER = 'max_versions.iedriver';
79-
const maxVersionsIedriverOption: yargs.Options = {
80-
describe: 'The ie driver max version used only for update.',
81-
type: 'string'
82-
};
83-
const MAX_VERSIONS_SELENIUM_ALIAS = 'max_versions.standalone';
84-
const MAX_VERSIONS_SELENIUM = 'max_versions.selenium';
85-
const maxVersionsSeleniumOption: yargs.Options = {
86-
describe: 'The selenium server standalone max version used only for update.',
87-
type: 'string'
88-
};
89-
9061
const OUT_DIR = 'out_dir';
9162
const outDirOption: yargs.Options = {
9263
describe: 'Location of output.',
@@ -108,40 +79,34 @@ const seleniumLogLevelOption: yargs.Options = {
10879
describe: 'Set the -Dselenium.LOGGER.level flag when starting the server',
10980
type: 'string'
11081
};
111-
const SELENIUM_ALIAS = 'standalone';
112-
const SELENIUM = 'selenium';
113-
const seleniumOption: yargs.Options = {
82+
const STANDALONE = 'standalone';
83+
const standaloneOption: yargs.Options = {
11484
describe: 'Install or update selenium server standalone.',
11585
default: true,
11686
type: 'boolean'
11787
};
118-
const SELENIUM_NODE_ALIAS = 'standalone_node';
119-
const SELENIUM_NODE = 'selenium_node';
120-
const seleniumNodeOption: yargs.Options = {
88+
const STANDALONE_NODE = 'standalone_node';
89+
const standaloneNodeOption: yargs.Options = {
12190
describe: 'Start the selenium server standalone with role set to "node".',
12291
type: 'boolean'
12392
};
124-
const VERSIONS_CHROMEDRIVER_ALIAS = 'versions.chrome';
125-
const VERSIONS_CHROMEDRIVER = 'versions.chromedriver';
126-
const versionsChromedriverOption: yargs.Options = {
93+
const VERSIONS_CHROME = 'versions.chrome';
94+
const versionsChromeOption: yargs.Options = {
12795
describe: 'The chromedriver version.',
12896
type: 'string'
12997
};
130-
const VERSIONS_GECKODRIVER_ALIAS = 'versions.gecko';
131-
const VERSIONS_GECKODRIVER = 'versions.geckodriver';
132-
const versionsGeckodriverOption: yargs.Options = {
98+
const VERSIONS_GECKO = 'versions.gecko';
99+
const versionsGeckoOption: yargs.Options = {
133100
describe: 'The geckodriver version.',
134101
type: 'string'
135102
};
136-
const VERSIONS_IEDRIVER_ALIAS = 'versions.ie';
137-
const VERSIONS_IEDRIVER = 'versions.iedriver';
138-
const versionsIedriverOption: yargs.Options = {
103+
const VERSIONS_IE = 'versions.ie';
104+
const versionsIeOption: yargs.Options = {
139105
describe: 'The ie driver version.',
140106
type: 'string'
141107
};
142-
const VERSIONS_SELENIUM_ALIAS = 'versions.standalone';
143-
const VERSIONS_SELENIUM = 'versions.selenium';
144-
const versionsSeleniumOption: yargs.Options = {
108+
const VERSIONS_STANDALONE = 'versions.standalone';
109+
const versionsStandaloneOption: yargs.Options = {
145110
describe: 'The selenium server standalone version.',
146111
type: 'string'
147112
};
@@ -168,33 +133,22 @@ yargs
168133
.command(
169134
'start', 'Start up the selenium server.',
170135
(yargs: yargs.Argv) => {
171-
return yargs
172-
.option(CHROMEDRIVER, chromedriverOption)
173-
.alias(CHROMEDRIVER_ALIAS, CHROMEDRIVER)
174-
.option(CHROMEDRIVER_LOGS, chromedriverLogsOption)
175-
.alias(CHROMEDRIVER_LOGS_ALIAS, CHROMEDRIVER_LOGS)
136+
return yargs.option(CHROME, chromeOption)
137+
.option(CHROME_LOGS, chromeLogsOption)
176138
.option(DETACH, detachOption)
177139
.option(EDGE, edgeOption)
178-
.option(GECKODRIVER, geckodriverOption)
179-
.alias(GECKODRIVER_ALIAS, GECKODRIVER)
180-
.option(IEDRIVER, iedriverOption)
181-
.alias(IEDRIVER_ALIAS, IEDRIVER)
140+
.option(GECKO, geckoOption)
141+
.option(IEDRIVER, ieOption)
182142
.option(LOG_LEVEL, logLevelOption)
183143
.option(OUT_DIR, outDirOption)
184-
.option(SELENIUM, seleniumOption)
185-
.alias(SELENIUM_ALIAS, SELENIUM)
186-
.option(SELENIUM_LOG_LEVEL, seleniumLogLevelOption)
187-
.option(SELENIUM_NODE, seleniumNodeOption)
188-
.alias(SELENIUM_NODE_ALIAS, SELENIUM_NODE)
189144
.option(SELENIUM_PORT, seleniumPort)
190-
.option(VERSIONS_CHROMEDRIVER, versionsChromedriverOption)
191-
.alias(VERSIONS_CHROMEDRIVER_ALIAS, VERSIONS_CHROMEDRIVER)
192-
.option(VERSIONS_GECKODRIVER, versionsGeckodriverOption)
193-
.alias(VERSIONS_GECKODRIVER_ALIAS, VERSIONS_GECKODRIVER)
194-
.option(VERSIONS_IEDRIVER, versionsIedriverOption)
195-
.alias(VERSIONS_IEDRIVER_ALIAS, VERSIONS_IEDRIVER)
196-
.option(VERSIONS_SELENIUM, versionsSeleniumOption)
197-
.alias(VERSIONS_SELENIUM_ALIAS, VERSIONS_SELENIUM);
145+
.option(SELENIUM_LOG_LEVEL, seleniumLogLevelOption)
146+
.option(STANDALONE, standaloneOption)
147+
.option(STANDALONE_NODE, standaloneNodeOption)
148+
.option(VERSIONS_CHROME, versionsChromeOption)
149+
.option(VERSIONS_GECKO, versionsGeckoOption)
150+
.option(VERSIONS_IE, versionsIeOption)
151+
.option(VERSIONS_STANDALONE, versionsStandaloneOption);
198152
},
199153
(argv: yargs.Arguments) => {
200154
start.handler(argv);
@@ -212,34 +166,19 @@ yargs
212166
'update', 'Install or update selected binaries.',
213167
(yargs: yargs.Argv) => {
214168
return yargs.option(OUT_DIR, outDirOption)
215-
.option(CHROMEDRIVER, chromedriverOption)
216-
.alias(CHROMEDRIVER_ALIAS, CHROMEDRIVER)
217-
.option(GECKODRIVER, geckodriverOption)
218-
.alias(GECKODRIVER_ALIAS, GECKODRIVER)
169+
.option(CHROME, chromeOption)
170+
.option(GECKO, geckoOption)
219171
.option(GITHUB_TOKEN, githubTokenOption)
220-
.option(IEDRIVER, iedriverOption)
221-
.alias(IEDRIVER_ALIAS, IEDRIVER)
172+
.option(IEDRIVER, ieOption)
222173
.option(IGNORE_SSL, ignoreSSLOption)
223174
.option(LOG_LEVEL, logLevelOption)
224-
.option(MAX_VERSIONS_CHROMEDRIVER, maxVersionsChromedriverOption)
225-
.alias(MAX_VERSIONS_CHROMEDRIVER_ALIAS, MAX_VERSIONS_CHROMEDRIVER)
226-
.option(MAX_VERSIONS_GECKODRIVER, maxVersionsGeckodriverOption)
227-
.alias(MAX_VERSIONS_GECKODRIVER_ALIAS, MAX_VERSIONS_GECKODRIVER)
228-
.option(MAX_VERSIONS_IEDRIVER, maxVersionsIedriverOption)
229-
.alias(MAX_VERSIONS_IEDRIVER_ALIAS, MAX_VERSIONS_IEDRIVER)
230-
.option(MAX_VERSIONS_SELENIUM, maxVersionsSeleniumOption)
231175
.option(OUT_DIR, outDirOption)
232176
.option(PROXY, proxyOption)
233-
.option(SELENIUM, seleniumOption)
234-
.alias(SELENIUM_ALIAS, SELENIUM)
235-
.option(VERSIONS_CHROMEDRIVER, versionsChromedriverOption)
236-
.alias(VERSIONS_CHROMEDRIVER_ALIAS, VERSIONS_CHROMEDRIVER)
237-
.option(VERSIONS_GECKODRIVER, versionsGeckodriverOption)
238-
.alias(VERSIONS_GECKODRIVER_ALIAS, VERSIONS_GECKODRIVER)
239-
.option(VERSIONS_IEDRIVER, versionsIedriverOption)
240-
.alias(VERSIONS_IEDRIVER_ALIAS, VERSIONS_IEDRIVER)
241-
.option(VERSIONS_SELENIUM, versionsSeleniumOption)
242-
.alias(VERSIONS_SELENIUM_ALIAS, VERSIONS_SELENIUM);
177+
.option(STANDALONE, standaloneOption)
178+
.option(VERSIONS_CHROME, versionsChromeOption)
179+
.option(VERSIONS_GECKO, versionsGeckoOption)
180+
.option(VERSIONS_IE, versionsIeOption)
181+
.option(VERSIONS_STANDALONE, versionsStandaloneOption);
243182
},
244183
(argv: yargs.Arguments) => {
245184
update.handler(argv);

lib/cmds/cmds.spec-e2e.ts

+7-7
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ describe('using the cli', () => {
3939
xit('should download the files', async () => {
4040
const argv = {
4141
_: ['foobar'],
42-
chromedriver: true,
43-
selenium: true,
42+
chrome: true,
43+
standalone: true,
4444
out_dir: tmpDir,
4545
'$0': 'bin\\webdriver-manager'
4646
};
@@ -70,9 +70,9 @@ describe('using the cli', () => {
7070
xit('should start the selenium server standalone in role=node', async () => {
7171
const argv = {
7272
_: ['foobar'],
73-
chromedriver: true,
74-
selenium: true,
75-
selenium_node: true,
73+
chrome: true,
74+
standalone: true,
75+
standalone_node: true,
7676
out_dir: tmpDir,
7777
'$0': 'bin\\webdriver-manager'
7878
};
@@ -104,8 +104,8 @@ describe('using the cli', () => {
104104
xit('should start the selenium server standalone', async () => {
105105
const argv = {
106106
_: ['foobar'],
107-
chromedriver: true,
108-
selenium: true,
107+
chrome: true,
108+
standalone: true,
109109
out_dir: tmpDir,
110110
'$0': 'bin\\webdriver-manager'
111111
};

lib/cmds/options.ts

+1-7
Original file line numberDiff line numberDiff line change
@@ -16,18 +16,14 @@ export interface Options {
1616
githubToken?: string;
1717
}
1818

19-
export type BrowserDriverName = 'chromedriver'|'geckodriver'|'iedriver';
20-
2119
/**
2220
* Contains information about a browser driver.
2321
*/
2422
export interface BrowserDriver {
2523
// The name of the browser driver.
26-
name?: BrowserDriverName;
24+
name?: 'chromedriver'|'geckodriver'|'iedriver';
2725
// The version which does not have to follow semver.
2826
version?: string;
29-
// A max version that either fully or partially matches the version.
30-
maxVersion?: string;
3127
}
3228

3329
/**
@@ -39,8 +35,6 @@ export interface Server {
3935
name?: 'selenium';
4036
// The version which does not have to follow semver.
4137
version?: string;
42-
// A max version that either fully or partially matches the version.
43-
maxVersion?: string;
4438
// Run as role = node option.
4539
runAsNode?: boolean;
4640
// The relative or full path to the chrome logs file.

lib/cmds/update.ts

+3-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const log = loglevel.getLogger('webdriver-manager');
1111
* @param argv The argv from yargs.
1212
*/
1313
export async function handler(argv: yargs.Arguments) {
14-
log.setLevel(argv['log_level']);
14+
log.setLevel(argv.log_level);
1515
const options = convertArgs2Options(argv);
1616
await update(options);
1717
}
@@ -35,14 +35,12 @@ export function updateBinary(optionsBinary: OptionsBinary): Promise<void[]> {
3535
const promises = [];
3636
if (optionsBinary.browserDrivers) {
3737
for (const provider of optionsBinary.browserDrivers) {
38-
promises.push(provider.binary.updateBinary(provider.version,
39-
provider.maxVersion));
38+
promises.push(provider.binary.updateBinary(provider.version));
4039
}
4140
}
4241
if (optionsBinary.server && optionsBinary.server.binary) {
4342
promises.push(
44-
optionsBinary.server.binary.updateBinary(optionsBinary.server.version,
45-
optionsBinary.server.maxVersion));
43+
optionsBinary.server.binary.updateBinary(optionsBinary.server.version));
4644
}
4745
return Promise.all(promises);
4846
}

lib/cmds/utils.spec-unit.ts

+19-5
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,30 @@ describe('utils', () => {
66
const argv = {
77
_: ['foobar'],
88
proxy: 'http://some.proxy.com',
9-
versions: {geckodriver: '0.16.0', chromedriver: '2.20'},
9+
versions: {gecko: '0.16.0', chrome: '2.20'},
1010
out_dir: 'foobar_download',
1111
ignore_ssl: false,
1212
'$0': 'bin\\webdriver-manager'
1313
};
1414
const options = convertArgs2AllOptions(argv);
1515
expect(options.browserDrivers).toBeTruthy();
1616
expect(options.browserDrivers.length).toBe(3);
17+
for (const provider of options.browserDrivers) {
18+
if (provider.name === 'geckodriver') {
19+
expect(provider.version).toBe('0.16.0');
20+
}
21+
if (provider.name === 'chromedriver') {
22+
expect(provider.version).toBe('2.20');
23+
}
24+
if (provider.name === 'iedriver') {
25+
expect(provider.version).toBeUndefined();
26+
}
27+
}
1728
expect(options.server).toBeTruthy();
1829
expect(options.server.name).toBe('selenium');
30+
expect(options.server.version).toBeUndefined();
31+
expect(options.proxy).toBe('http://some.proxy.com');
32+
expect(options.ignoreSSL).toBeFalsy();
1933
expect(options.outDir).toBe('foobar_download');
2034
});
2135
});
@@ -24,10 +38,10 @@ describe('utils', () => {
2438
it('should create the default providers', () => {
2539
const argv = {
2640
_: ['foobar'],
27-
chromedriver: true,
28-
geckodriver: true,
29-
selenium: true,
30-
versions: {geckodriver: '0.16.0', chromedriver: '2.20'},
41+
chrome: true,
42+
gecko: true,
43+
standalone: true,
44+
versions: {gecko: '0.16.0', chrome: '2.20'},
3145
out_dir: 'foobar_download',
3246
'$0': 'bin\\webdriver-manager'
3347
};

0 commit comments

Comments
 (0)