Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prep export of launcher as a standalone module #2358

Merged
merged 6 commits into from
Jun 13, 2017
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ echo "Upload the package zip to CWS dev dashboard"

echo "Verify the npm package won't include unncessary files"
yarn global add irish-pub pkgfiles
irish-pub; pkgfiles;
irish-pub; pkgfiles;

echo "ship it"
npm publish
Expand All @@ -110,6 +110,17 @@ echo "Generate the release notes, and update the release page"
echo "Inform various peoples"
```

### Releasing chrome launcher.

```sh
cd chrome-launcher
echo "build the launcher source code"
yarn build
echo "run npm version [<newversion> | major | minor | patch | premajor | preminor | prepatch | prerelease | from-git]"
echo "commit the change as a version bump"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how about suggesting npm version (major|minor|patch)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

already updated :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i prefer versioning with yarn because it's interactive, but w/e. also in both cases the commit (and tag) is made automatically.

yarn version
echo "version bump will be committed"

npm publish
```

### Canary release

```sh
Expand Down
11 changes: 11 additions & 0 deletions chrome-launcher/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# folders
.vscode/
test/

# dev files
.appveyor.yml
.editorconfig
.eslintignore
.eslintrc.js
.travis.yml
gulpfile.js
80 changes: 80 additions & 0 deletions chrome-launcher/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
# Chrome Launcher

Launch chrome with ease from node.

### Installing

```
yarn add chrome-launcher
```

or

```
npm install chrome-launcher
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yarn add chrome-launcher
# npm install chrome-launcher 

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

```


## API

#### Launch options

```js
chromeLauncher.launch({
// optional staring url string
startingUrl: string;
// optional array of (string) flags to pass to chrome, for example ['--headless', '--disable-gpu']
// See all flags here: http://peter.sh/experiments/chromium-command-line-switches/
chromeFlags: Array<string>;
// optional explicit remote debugging port number to use, otherwise an open port is autoselected for you.
port: number;
// optional, handle cleaning up chrome when node process gets killed via SIGINT
handleSIGINT: boolean;
// optional, explicit path to chrome to launch
chromePath: string;
// optional, user dir path to reuse
userDataDir: string;
});
```

#### Launched chrome interface

```js
{
// process id of chrome.
pid: number;
// the remote debuging port exposed by the launched chrome.
port: number;
// a function to kill and cleanup chrome.
kill: () => Promise<{}>;
}
```


## Examples

#### Launching chrome:

```js
const chromeLauncher = require('chrome-launcher');

chromeLauncher.launch({
startingUrl: 'https://google.com'
}).then(info => {
console.log(`Chrome debugging port running on ${info.port}`);
});
```


#### Launching headless chrome:

```js
const chromeLauncher = require('chrome-launcher');

chromeLauncher.launch({
startingUrl: 'https://google.com',
chromeFlags: ['--headless', '--disable-gpu']
}).then(info => {
console.log(`Chrome debugging port running on ${info.port}`);
});
```
2 changes: 1 addition & 1 deletion chrome-launcher/chrome-launcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {DEFAULT_FLAGS} from './flags';
import {makeTmpDir, defaults, delay} from './utils';
import * as net from 'net';
const rimraf = require('rimraf');
const log = require('../lighthouse-core/lib/log');
const log = require('lighthouse/lighthouse-core/lib/log');
const spawn = childProcess.spawn;
const execSync = childProcess.execSync;
const isWindows = process.platform === 'win32';
Expand Down
11 changes: 8 additions & 3 deletions chrome-launcher/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
{
"name": "chrome-launcher",
"private": true,
"main": "chrome-launcher.js",
"scripts": {
"build": "tsc",
Expand All @@ -19,6 +18,12 @@
"dependencies": {
"@types/core-js": "^0.9.41",
"@types/mkdirp": "^0.3.29",
"@types/node": "6.0.66"
}
"@types/node": "6.0.66",
"lighthouse": "2.1"
},
"version": "0.1.0",
"description": "Launch latest Chrome with the devtools-protocol port open",
"repository": "https://github.com/GoogleChrome/lighthouse/tree/master/chrome-launcher",
"author": "The Chromium Authors",
"license": "Apache-2.0"
}
Loading