Skip to content

Commit

Permalink
feat: use node and @puppeteer/browsers to install and sync Chrome and…
Browse files Browse the repository at this point in the history
… ChromeDriver (#14)

* feat: use @puppeteer/browsers to download and sync browsers

* test: use @puppeteer/browsers

* chore: remove unused shell scripts

* chore: remove unused user-files dir placeholder

* chore: add @puppeteer/browsers dependency

* docs: update README.md

* chore: update version

* fix: revert version increase

* test: throw if detectBrowserPlatform returns undefined

* feat: display download progress given the --verbose option

* chore: refactor version and which to use commander

* test: showing download progress with verbose flag

* fix: refactor getEnv to remove race condition

* chore: rename filePath to env

* chore: use promise versions of fs

* feat: throw if an unsupported browser is given

* test: unsupported browser and missing env file.

* fix: remove redundant resolveBuildId call.

* chore: clean up

* test: show version without context.

* fix: console error s should all throw instead

* chore: refactor to use chai-as-promised

* test: downloadProgressCallback, and fixes

* docs: replace install command

* chore: remove unused capitalize function

* feat: second installation, feedback response

* docs: add JSDocs and remove redundant comments.

* all tests passing again

* test: invalid version in env file

* improve error messages

* chore: wrap console.log stub where it's tested or should be suppressed

* chore: remove utils file

* jsdocs

* use 'stable' as default version

Co-authored-by: Steven Lambert <[email protected]>

* replace version option

Co-authored-by: Steven Lambert <[email protected]>

* handle version global option

* uninstall last

* test invalid installations; always await wrapConsoleLobStub

---------

Co-authored-by: Steven Lambert <[email protected]>
  • Loading branch information
scottmries and straker authored Jun 6, 2024
1 parent c610d9c commit 469d008
Show file tree
Hide file tree
Showing 48 changed files with 2,974 additions and 8,072 deletions.
64 changes: 18 additions & 46 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ npm install browser-driver-manager
## Usage

```terminal
npx browser-driver-manager install chrome chromedriver
npx browser-driver-manager install chrome
```

Managing browsers and drivers for continuous integration, especially Chrome and ChromeDriver, can be extremely difficult, if not utterly frustrating.
Expand All @@ -36,7 +36,7 @@ Here's an example of doing just that in an npm script.
```json
{
"scripts": {
"install:chromedriver": "browser-driver-manager install chromedriver"
"install:chrome": "browser-driver-manager install chrome"
}
}
```
Expand All @@ -46,82 +46,54 @@ If you wanted to install Chrome Beta and its associated driver:
```json
{
"scripts": {
"install:chromedriver": "browser-driver-manager install chrome=beta chromedriver=beta"
"install:chromedriver": "browser-driver-manager install chrome@beta"
}
}
```

## Supported Platforms and Browsers

Currently only MacOS and Linux platforms, and Chrome browser and drivers are supported. Firefox support is planned.

Currently there are no plans to support Windows. If you need Windows support please reach out, but understand that adding Windows support is a paid feature request.
MacOS, Linux, and Windows platforms, and Chrome browser and drivers are supported. Firefox support is planned.

## System Requirements

Using the `version` or `which` commands do not require any bash built in commands. The `install` bash command requires the following support:
Node is required to run commands.

- `curl` or `wget` to download files
- `dpkg` or `rpm` to extract browser applications
- `apt` or `yum` to install browsers
- `unzip` to install ChromeDriver (if using the bash script directly)
Install dependencies with

Additionally, `sudo` permissions are needed in order to install browsers.
`npm install`

## Commands and Options

### Commands

- **install:**
Install one or multiple browsers or drivers Can also pass the specific browser channel or driver version for each browser or driver. The latest Stable channel is used if no channel is passed. When installing ChromeDriver without passing a channel or version, the ChromeDriver version that matches the installed Stable version of Chrome is used.
Install the browser and driver. Can also pass the specific browser channel or version for each browser and driver. The latest Stable channel is used if no channel is passed.

```bash
# Install latest Chrome Stable
# Install latest Chrome Stable and matching Chromedriver version
browser-driver-manager install chrome

# Install ChromeDriver version that matches install Chrome Stable
browser-driver-manager install chromedriver

# Install latest Chrome Beta
browser-driver-manager install chrome=beta

# Install ChromeDriver version 97
browser-driver-manager install chromedriver=97

# Install both Chrome and ChromeDriver Beta
browser-driver-manager install chrome=beta chromedriver=beta
```
# Install latest Chrome Beta and matching Chromedriver
browser-driver-manager install chrome@beta

- **version:**
Get the installed version of the browser or driver. Can also pass the specific browser channel.
Get the installed version of the browser or driver.

```bash
# Get installed Chrome version
browser-driver-manager version chrome
# Get installed Chrome Beta version
browser-driver-manager version chrome=beta
# Get ChromeDriver version
browser-driver-manager version chromedriver
```
# Get installed Chrome and Chromedriver versions
browser-driver-manager version
- **which:**
Get the installed location of the browser or driver. Can also pass the specific browser channel.
Get the installed location of the browser and driver.
```bash
# Get installed Chrome location
browser-driver-manager which chrome
# Get installed Chrome Beta location
browser-driver-manager which chrome=beta
# Get ChromeDriver location
browser-driver-manager which chromedriver
# Get installed Chrome and Chromedriver locations
browser-driver-manager which
```

### Options

- **-h,--help:** Display the help information
- **-v,--version:** Display the version information
- **--verbose:** Output verbose logs
- **-v,--version:** Display the version information
29 changes: 27 additions & 2 deletions bin/browser-driver-manager
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
#!/usr/bin/env node
const { install, version, which } = require('../src/browser-driver-manager.js');
const { Command } = require('commander');
const { version: pkgVersion } = require('../package.json');

const browserDriverManager = require('../src/browser-driver-manager.js');
const program = new Command();

browserDriverManager(process.argv.slice(2));
program.version(pkgVersion, '-v, --version');

program.command('which')
.description('displays the locations of the installed browser and driver')
.action(which);
program.command('version')
.description('displays the version of the installed browser and driver')
.action(version);
program.command('install')
.description('installs browsers and drivers')
.argument('<browser>', 'the browser and driver to install. Use "chrome" to install Chrome and Chromedriver')
.option('--verbose', 'display additional information about the download process.')
.action(install);

program.addHelpText('after', `
Examples:
browser-driver-manager install chrome
browser-driver-manager install chrome@beta
browser-driver-manager version
browser-driver-manager which`)

program.parse();
Loading

0 comments on commit 469d008

Please sign in to comment.