find-chrome-bin
Advanced tools
Comparing version 1.0.5 to 2.0.0
@@ -5,2 +5,7 @@ # Change Log | ||
## 2.0.0 | ||
- Dropped support for CommonJS | ||
- Switched to using @puppeteer/browsers to download the browser | ||
## 1.0.5 | ||
@@ -7,0 +12,0 @@ |
12
index.js
@@ -1,7 +0,7 @@ | ||
const { isSuitableVersion, chromeVersion, downloadChromium } = require('./src/chrome') | ||
const { findChromeBinaryOnDarwin } = require('./src/darwin') | ||
const { findChromeBinaryOnLinux } = require('./src/linux') | ||
const { findChromeBinaryOnWin32 } = require('./src/win32') | ||
import { isSuitableVersion, chromeVersion, downloadChromium } from './src/chrome/index.js' | ||
import { findChromeBinaryOnDarwin } from './src/darwin/index.js' | ||
import { findChromeBinaryOnLinux } from './src/linux/index.js' | ||
import { findChromeBinaryOnWin32 } from './src/win32/index.js' | ||
async function findChrome({ min, max, download: { puppeteer, path, revision } = {} } = {}) { | ||
export async function findChrome({ min, max, download: { puppeteer, path, revision } = {} } = {}) { | ||
try { | ||
@@ -56,3 +56,1 @@ let executablePath = findChromeBinaryPath() | ||
} | ||
module.exports = { findChrome } |
{ | ||
"name": "find-chrome-bin", | ||
"version": "1.0.5", | ||
"version": "2.0.0", | ||
"description": "Finds local Chromium binary to use it with puppeteer-core", | ||
@@ -17,4 +17,5 @@ "keywords": [ | ||
"engines": { | ||
"node": ">=14.0.0" | ||
"node": ">=18.0.0" | ||
}, | ||
"type": "module", | ||
"types": "./index.d.ts", | ||
@@ -26,18 +27,21 @@ "scripts": { | ||
}, | ||
"dependencies": { | ||
"@puppeteer/browsers": "^1.8.0" | ||
}, | ||
"devDependencies": { | ||
"@logux/eslint-config": "^49.0.0", | ||
"@size-limit/preset-small-lib": "^8.2.4", | ||
"check-dts": "^0.7.1", | ||
"eslint": "^8.36.0", | ||
"eslint-config-standard": "^17.0.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"eslint-plugin-n": "^15.6.1", | ||
"@logux/eslint-config": "^52.0.2", | ||
"@size-limit/preset-small-lib": "^11.0.0", | ||
"check-dts": "^0.7.2", | ||
"eslint": "^8.54.0", | ||
"eslint-config-standard": "^17.1.0", | ||
"eslint-plugin-import": "^2.29.0", | ||
"eslint-plugin-n": "^16.3.1", | ||
"eslint-plugin-node": "^11.1.0", | ||
"eslint-plugin-prefer-let": "^3.0.1", | ||
"eslint-plugin-promise": "^6.1.1", | ||
"nanospy": "^0.5.0", | ||
"puppeteer-core": "^19.8.0", | ||
"size-limit": "^8.2.4", | ||
"nanospy": "^1.0.0", | ||
"puppeteer-core": "^21.5.2", | ||
"size-limit": "^11.0.0", | ||
"tsm": "^2.3.0", | ||
"typescript": "^5.0.2", | ||
"typescript": "^5.3.2", | ||
"uvu": "^0.5.6" | ||
@@ -44,0 +48,0 @@ }, |
@@ -1,7 +0,12 @@ | ||
const { execSync } = require('child_process') | ||
import { execSync } from 'child_process' | ||
import { install } from '@puppeteer/browsers' | ||
const { MIN_CHROME_VERSION, MAX_CHROME_VERSION } = require('../utils') | ||
const { getWin32ChromeVersionInfo } = require('../win32') | ||
import { MIN_CHROME_VERSION, MAX_CHROME_VERSION } from '../utils/index.js' | ||
import { getWin32ChromeVersionInfo } from '../win32/index.js' | ||
function isSuitableVersion(executablePath, min = MIN_CHROME_VERSION, max = MAX_CHROME_VERSION) { | ||
export function isSuitableVersion( | ||
executablePath, | ||
min = MIN_CHROME_VERSION, | ||
max = MAX_CHROME_VERSION | ||
) { | ||
if (min > max) { | ||
@@ -37,3 +42,3 @@ throw new Error( | ||
function chromeVersion(executablePath) { | ||
export function chromeVersion(executablePath) { | ||
return ( | ||
@@ -46,25 +51,13 @@ process.platform === 'win32' | ||
async function downloadChromium(puppeteer, path, revision) { | ||
export async function downloadChromium(puppeteer, path, revision) { | ||
try { | ||
let downloadHost = | ||
process.env.PUPPETEER_DOWNLOAD_HOST || | ||
process.env.npm_config_puppeteer_download_host || | ||
process.env.npm_package_config_puppeteer_download_host | ||
const config = { | ||
buildId: revision, | ||
browser: 'chrome', | ||
unpack: true, | ||
cacheDir: path | ||
} | ||
let browserFetcher = new puppeteer.BrowserFetcher({ path, host: downloadHost }) | ||
let newRevisionInfo = await install(config) | ||
let revisionInfo = browserFetcher.revisionInfo(revision) | ||
// If already downloaded | ||
if (revisionInfo.local) return revisionInfo | ||
let newRevisionInfo = await browserFetcher.download(revisionInfo.revision) | ||
let localRevisions = await browserFetcher.localRevisions() | ||
localRevisions = localRevisions.filter(r => r !== revisionInfo.revision) | ||
// Remove previous revisions | ||
let cleanupOldVersions = localRevisions.map(r => browserFetcher.remove(r)) | ||
await Promise.all(cleanupOldVersions) | ||
return newRevisionInfo | ||
@@ -76,3 +69,1 @@ } catch (error) { | ||
} | ||
module.exports = { isSuitableVersion, chromeVersion, downloadChromium } |
@@ -1,7 +0,7 @@ | ||
const { join } = require('path') | ||
const { execSync } = require('child_process') | ||
import { join } from 'path' | ||
import { execSync } from 'child_process' | ||
const { newLineRegex, canAccess } = require('../utils') | ||
import { newLineRegex, canAccess } from '../utils/index.js' | ||
function findChromeBinaryOnDarwin(canary) { | ||
export function findChromeBinaryOnDarwin(canary) { | ||
let LSREGISTER = | ||
@@ -37,3 +37,1 @@ '/System/Library/Frameworks/CoreServices.framework' + | ||
} | ||
module.exports = { findChromeBinaryOnDarwin } |
@@ -1,8 +0,8 @@ | ||
const { join } = require('path') | ||
const { execSync, execFileSync } = require('child_process') | ||
const { homedir } = require('os') | ||
import { join } from 'path' | ||
import { execSync, execFileSync } from 'child_process' | ||
import { homedir } from 'os' | ||
const { newLineRegex, canAccess } = require('../utils') | ||
import { newLineRegex, canAccess } from '../utils/index.js' | ||
function findChromeBinaryOnLinux() { | ||
export function findChromeBinaryOnLinux() { | ||
let installations = [] | ||
@@ -96,3 +96,1 @@ | ||
} | ||
module.exports = { findChromeBinaryOnLinux } |
@@ -1,10 +0,10 @@ | ||
const { accessSync } = require('fs') | ||
import { accessSync } from 'fs' | ||
const MIN_CHROME_VERSION = 85 | ||
export const MIN_CHROME_VERSION = 85 | ||
const MAX_CHROME_VERSION = Number.MAX_VALUE | ||
export const MAX_CHROME_VERSION = Number.MAX_VALUE | ||
const newLineRegex = /\r?\n/ | ||
export const newLineRegex = /\r?\n/ | ||
function canAccess(file) { | ||
export function canAccess(file) { | ||
if (!file) { | ||
@@ -21,8 +21,1 @@ return false | ||
} | ||
module.exports = { | ||
MIN_CHROME_VERSION, | ||
MAX_CHROME_VERSION, | ||
newLineRegex, | ||
canAccess | ||
} |
@@ -1,7 +0,7 @@ | ||
const { sep, join } = require('path') | ||
const { execSync } = require('child_process') | ||
import { sep, join } from 'path' | ||
import { execSync } from 'child_process' | ||
const { canAccess } = require('../utils') | ||
import { canAccess } from '../utils/index.js' | ||
function findChromeBinaryOnWin32(canary) { | ||
export function findChromeBinaryOnWin32(canary) { | ||
let suffix = canary | ||
@@ -27,3 +27,3 @@ ? `${sep}Google${sep}Chrome SxS${sep}Application${sep}chrome.exe` | ||
function getWin32ChromeVersionInfo(executablePath) { | ||
export function getWin32ChromeVersionInfo(executablePath) { | ||
let executablePathForNode = executablePath.replace(/\\/g, '\\\\') | ||
@@ -67,3 +67,1 @@ let wmiResult = execSync( | ||
} | ||
module.exports = { findChromeBinaryOnWin32, getWin32ChromeVersionInfo } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 3 instances in 1 package
8
Yes
18892
1
14
384
+ Added@puppeteer/browsers@^1.8.0
+ Added@puppeteer/browsers@1.9.1(transitive)
+ Added@tootallnate/quickjs-emscripten@0.23.0(transitive)
+ Added@types/node@22.9.0(transitive)
+ Added@types/yauzl@2.10.3(transitive)
+ Addedagent-base@7.1.1(transitive)
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedast-types@0.13.4(transitive)
+ Addedb4a@1.6.7(transitive)
+ Addedbare-events@2.5.0(transitive)
+ Addedbase64-js@1.5.1(transitive)
+ Addedbasic-ftp@5.0.5(transitive)
+ Addedbuffer@5.7.1(transitive)
+ Addedbuffer-crc32@0.2.13(transitive)
+ Addedcliui@8.0.1(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addeddata-uri-to-buffer@6.0.2(transitive)
+ Addeddebug@4.3.4(transitive)
+ Addeddegenerator@5.0.1(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedend-of-stream@1.4.4(transitive)
+ Addedescalade@3.2.0(transitive)
+ Addedescodegen@2.1.0(transitive)
+ Addedesprima@4.0.1(transitive)
+ Addedestraverse@5.3.0(transitive)
+ Addedesutils@2.0.3(transitive)
+ Addedextract-zip@2.0.1(transitive)
+ Addedfast-fifo@1.3.2(transitive)
+ Addedfd-slicer@1.1.0(transitive)
+ Addedfs-extra@11.2.0(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedget-stream@5.2.0(transitive)
+ Addedget-uri@6.0.3(transitive)
+ Addedgraceful-fs@4.2.11(transitive)
+ Addedhttp-proxy-agent@7.0.2(transitive)
+ Addedhttps-proxy-agent@7.0.5(transitive)
+ Addedieee754@1.2.1(transitive)
+ Addedip-address@9.0.5(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedjsbn@1.1.0(transitive)
+ Addedjsonfile@6.1.0(transitive)
+ Addedlru-cache@7.18.3(transitive)
+ Addedmkdirp-classic@0.5.3(transitive)
+ Addedms@2.1.2(transitive)
+ Addednetmask@2.0.2(transitive)
+ Addedonce@1.4.0(transitive)
+ Addedpac-proxy-agent@7.0.2(transitive)
+ Addedpac-resolver@7.0.1(transitive)
+ Addedpend@1.2.0(transitive)
+ Addedprogress@2.0.3(transitive)
+ Addedproxy-agent@6.3.1(transitive)
+ Addedproxy-from-env@1.1.0(transitive)
+ Addedpump@3.0.2(transitive)
+ Addedqueue-tick@1.0.1(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedsmart-buffer@4.2.0(transitive)
+ Addedsocks@2.8.3(transitive)
+ Addedsocks-proxy-agent@8.0.4(transitive)
+ Addedsource-map@0.6.1(transitive)
+ Addedsprintf-js@1.1.3(transitive)
+ Addedstreamx@2.20.2(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedtar-fs@3.0.4(transitive)
+ Addedtar-stream@3.1.7(transitive)
+ Addedtext-decoder@1.2.1(transitive)
+ Addedthrough@2.3.8(transitive)
+ Addedtslib@2.8.1(transitive)
+ Addedunbzip2-stream@1.4.3(transitive)
+ Addedundici-types@6.19.8(transitive)
+ Addeduniversalify@2.0.1(transitive)
+ Addedwrap-ansi@7.0.0(transitive)
+ Addedwrappy@1.0.2(transitive)
+ Addedy18n@5.0.8(transitive)
+ Addedyargs@17.7.2(transitive)
+ Addedyargs-parser@21.1.1(transitive)
+ Addedyauzl@2.10.0(transitive)