puppeteer-chromium-resolver
Advanced tools
Comparing version 2.0.0 to 2.0.1
47
index.js
@@ -31,8 +31,12 @@ const path = require('path'); | ||
//========================================================================================= | ||
let outputSilent = false; | ||
const output = (msg, isError) => { | ||
gauge.disable(); | ||
if (isError) { | ||
console.log(Color.red("[PCR] " + msg)); | ||
} else { | ||
console.log("[PCR] " + msg); | ||
if (!outputSilent) { | ||
if (isError) { | ||
console.log(Color.red("[PCR] " + msg)); | ||
} else { | ||
console.log("[PCR] " + msg); | ||
} | ||
} | ||
@@ -276,3 +280,2 @@ gauge.enable(); | ||
const detectionLocalChromium = (option) => { | ||
output("Detecting local chromium ..."); | ||
option.detectionList = initDetectionList(option); | ||
@@ -358,25 +361,21 @@ //output(detectionList.join("\n")); | ||
//Chromium | ||
revisionInfo.launchable = option.launchable; | ||
revisionInfo.chromiumVersion = option.chromiumVersion; | ||
var launchable = Color.red("false"); | ||
if (revisionInfo.launchable) { | ||
launchable = Color.green("true"); | ||
output("Chromium executablePath: " + revisionInfo.executablePath); | ||
if (revisionInfo.chromiumVersion) { | ||
output("Chromium version: " + revisionInfo.chromiumVersion); | ||
} | ||
} | ||
output("Chromium launchable: " + launchable); | ||
//Puppeteer | ||
revisionInfo.puppeteer = puppeteer; | ||
if (option.puppeteerConf) { | ||
revisionInfo.puppeteerVersion = option.puppeteerConf.version; | ||
} | ||
output("Chromium executablePath: " + revisionInfo.executablePath); | ||
var launchable = revisionInfo.launchable ? Color.green("true") : Color.red("false"); | ||
output("Chromium launchable: " + launchable); | ||
if (revisionInfo.chromiumVersion) { | ||
output("Chromium version: " + revisionInfo.chromiumVersion); | ||
output("Chromium " + Color.green("installed")); | ||
} else { | ||
output("Chromium installation: " + Color.red("failed")); | ||
} | ||
output("Puppeteer version: " + revisionInfo.puppeteerVersion); | ||
output("Puppeteer " + Color.green("installed")); | ||
@@ -396,8 +395,12 @@ return revisionInfo; | ||
hosts: [], | ||
retry: 3 | ||
retry: 3, | ||
silent: false | ||
}; | ||
option = Object.assign(defaultOption, option); | ||
outputSilent = option.silent; | ||
option.puppeteerConf = initPuppeteerConf(option); | ||
option.revision = initRevision(option); | ||
output("Require revision: " + option.revision); | ||
output("Chromium revision: " + option.revision); | ||
option.userFolder = initUserFolder(option); | ||
@@ -404,0 +407,0 @@ |
@@ -1,3 +0,3 @@ | ||
require("./index.js")({}).then((revisionInfo) => { | ||
//console.log(revisionInfo); | ||
require("./index.js")({}).then((pcr) => { | ||
//console.log(pcr); | ||
}); |
{ | ||
"name": "puppeteer-chromium-resolver", | ||
"version": "2.0.0", | ||
"description": "Tool to resolve puppeteer's chromium faster, detect local installed chromium, download chromium with custom/mirror host, cache chromium revision out of node_modules, test chromium headless being launchable.", | ||
"version": "2.0.1", | ||
"description": "Tool to resolve puppeteer and chromium faster, detect local installed chromium, download chromium with custom mirror host, cache chromium revision out of node_modules, test chromium headless being launchable.", | ||
"main": "index.js", | ||
@@ -6,0 +6,0 @@ "dependencies": { |
# Puppeteer Chromium Resolver | ||
> Tool to resolve puppeteer's chromium faster, detect local installed chromium, download chromium with custom/mirror host, cache chromium revision out of node_modules, test chromium headless being launchable. | ||
> Tool to resolve puppeteer and chromium faster, detect local installed chromium, download chromium with custom mirror host, cache chromium revision out of node_modules, test chromium headless being launchable. | ||
@@ -9,8 +9,8 @@ ![npm](https://img.shields.io/npm/v/puppeteer-chromium-resolver.svg) | ||
* A tool to customize [puppeteer](https://github.com/GoogleChrome/puppeteer) | ||
* Detect chromium from local path. | ||
* Download chromium from custom/mirror host. | ||
* Cache chromium to local. | ||
* Try to launch chromium and returns launchable property | ||
* Returns puppeteer and executablePath | ||
* Tool to customize [puppeteer](https://github.com/GoogleChrome/puppeteer) | ||
* Detect local chromium automatically | ||
* Download chromium from custom mirror host | ||
* Cache chromium to local folder | ||
* Try launching chromium and resolve launchable and version | ||
* Resolve chromium executablePath and puppeteer | ||
@@ -23,12 +23,12 @@ ## Install | ||
```js | ||
var puppeteerResolver = require("puppeteer-chromium-resolver"); | ||
var revisionInfo = await puppeteerResolver(); | ||
var browser = await revisionInfo.puppeteer.launch({ | ||
const PCR = require("puppeteer-chromium-resolver"); | ||
const pcr = await PCR(); | ||
const browser = await pcr.puppeteer.launch({ | ||
headless: true, | ||
args: ['--no-sandbox'], | ||
executablePath: revisionInfo.executablePath | ||
executablePath: pcr.executablePath | ||
}).catch(function (error) { | ||
console.log(error); | ||
}); | ||
var page = await browser.newPage(); | ||
const page = await browser.newPage(); | ||
await page.goto('https://www.google.com'); | ||
@@ -38,5 +38,5 @@ await browser.close(); | ||
## Default Option | ||
## Option | ||
```js | ||
var revisionInfo = await puppeteerResolver({ | ||
const pcr = await PCR({ | ||
revision: "", | ||
@@ -46,9 +46,24 @@ detectionPath: "", | ||
hosts: ["https://storage.googleapis.com", "https://npm.taobao.org/mirrors"], | ||
retry: 3 | ||
retry: 3, | ||
silent: false | ||
}); | ||
``` | ||
## Properties | ||
|Property | Type | | | ||
| :--------------| :------ | :---------------------- | | ||
|revision | String |current chromium revision | | ||
|executablePath | String |chromium executable path | | ||
|folderPath | String |chromium folder path | | ||
|local | Boolean |exists local chromium | | ||
|url | String |chromium download url | | ||
|launchable | Boolean |chromium launchable | | ||
|chromiumVersion | String |chromium version | | ||
|puppeteer | Object |puppeteer module | | ||
|puppeteerVersion| String |puppeteer version | | ||
## CHANGELOG | ||
+ v2.0.0 | ||
- refactoring | ||
+ v2.0.1 | ||
- updated puppeteer-core version to v1.19.0 | ||
- refactoring with async/await | ||
- fixed requesting timeout | ||
@@ -55,0 +70,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
17481
421
69
2