From 66ced61506b96c05e3d38aed7179690ca00e3766 Mon Sep 17 00:00:00 2001 From: Maksim Balabash Date: Tue, 21 Nov 2023 10:23:30 +0100 Subject: [PATCH] v2.0.0 --- .github/workflows/test.yml | 8 ++++---- CHANGELOG.md | 3 ++- index.js | 4 +++- package.json | 7 ++++--- test/index.test.js | 16 +++++++++------- yarn.lock | 24 +++++++++++++----------- 6 files changed, 35 insertions(+), 27 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 3bf4b87..9359c81 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,16 +4,16 @@ on: jobs: full: runs-on: ubuntu-latest - name: OS ubuntu-latest Node.js 19 + name: OS ubuntu-latest Node.js 18 steps: - name: Install Chrome - uses: browser-actions/setup-chrome@latest + uses: browser-actions/setup-chrome@latest - name: Checkout the repository uses: actions/checkout@v2 - - name: Install Node.js 19 + - name: Install Node.js 18 uses: actions/setup-node@v2 with: - node-version: 19 + node-version: 18 - name: Install dependencies run: yarn install --frozen-lockfile - name: Run unit tests diff --git a/CHANGELOG.md b/CHANGELOG.md index e41a5be..376447d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,8 +2,9 @@ This project adheres to [Semantic Versioning](http://semver.org/). -## 1.1.3 +## 2.0.0 +- Dropped support for CommonJS - Fixed type compatibility issue between puppeteer-core and puppeteer. - Upgraded devDependencies. diff --git a/index.js b/index.js index 501108c..3b3c6cb 100644 --- a/index.js +++ b/index.js @@ -45,4 +45,6 @@ function scrollPage(scrollDirection) { } } -module.exports = { scrollPageToBottom: scrollPage('bottom'), scrollPageToTop: scrollPage('top') } +export const scrollPageToBottom = scrollPage('bottom'); + +export const scrollPageToTop = scrollPage('top'); diff --git a/package.json b/package.json index 8679ca5..e523cbe 100644 --- a/package.json +++ b/package.json @@ -1,12 +1,13 @@ { "name": "puppeteer-autoscroll-down", - "version": "1.1.3", + "version": "2.0.0", "description": "Handle infinite scroll on websites with puppeteer", "main": "index.js", "types": "./index.d.ts", "engines": { - "node": ">=12" + "node": ">=18" }, + "type": "module", "license": "MIT", "author": "mbalabash ", "scripts": { @@ -39,7 +40,7 @@ "eslint-plugin-perfectionist": "^2.4.0", "eslint-plugin-prefer-let": "^3.0.1", "eslint-plugin-promise": "^6.1.1", - "find-chrome-bin": "1.0.5", + "find-chrome-bin": "2.0.0", "puppeteer-core": "^21.5.2", "tsm": "^2.3.0", "typescript": "^5.3.2", diff --git a/test/index.test.js b/test/index.test.js index 116cb49..c10249e 100644 --- a/test/index.test.js +++ b/test/index.test.js @@ -1,11 +1,13 @@ -const { test } = require('uvu') -const { join } = require('node:path') -const assert = require('uvu/assert') -const puppeteer = require('puppeteer-core') -const { findChrome } = require('find-chrome-bin') -const { PUPPETEER_REVISIONS } = require('puppeteer-core/lib/cjs/puppeteer/revisions.js') +import { findChrome } from 'find-chrome-bin' +import { dirname, join } from 'node:path' +import { fileURLToPath } from 'node:url'; +import puppeteer from 'puppeteer-core' +import { PUPPETEER_REVISIONS } from 'puppeteer-core/lib/cjs/puppeteer/revisions.js' +import { test } from 'uvu'; +import * as assert from 'uvu/assert'; -const { scrollPageToBottom, scrollPageToTop } = require('../index') +import { scrollPageToBottom, scrollPageToTop } from '../index.js' +const __dirname = dirname(fileURLToPath(import.meta.url)); test('should scroll `regular` page to bottom', async () => { let chromeInfo = await findChrome({ diff --git a/yarn.lock b/yarn.lock index 0eaf962..7d97712 100644 --- a/yarn.lock +++ b/yarn.lock @@ -116,7 +116,7 @@ "@nodelib/fs.scandir" "2.1.5" fastq "^1.6.0" -"@puppeteer/browsers@1.8.0": +"@puppeteer/browsers@1.8.0", "@puppeteer/browsers@^1.8.0": version "1.8.0" resolved "https://registry.yarnpkg.com/@puppeteer/browsers/-/browsers-1.8.0.tgz#fb6ee61de15e7f0e67737aea9f9bab1512dbd7d8" integrity sha512-TkRHIV6k2D8OlUe8RtG+5jgOF/H98Myx0M6AOafC8DdNVOFiBSFa5cpRDtpm8LXOa9sVwe0+e6Q3FC56X/DZfg== @@ -145,9 +145,9 @@ integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ== "@types/node@*": - version "20.9.2" - resolved "https://registry.yarnpkg.com/@types/node/-/node-20.9.2.tgz#002815c8e87fe0c9369121c78b52e800fadc0ac6" - integrity sha512-WHZXKFCEyIUJzAwh3NyyTHYSR35SevJ6mZ1nWwJafKtiQbqRTIKSRcw3Ma3acqgsent3RRDqeVwpHntMk+9irg== + version "20.9.3" + resolved "https://registry.yarnpkg.com/@types/node/-/node-20.9.3.tgz#e089e1634436f676ff299596c9531bd2b59fffc6" + integrity sha512-nk5wXLAXGBKfrhLB0cyHGbSqopS+nz0BUgZkUQqSHSSgdee0kssp1IAqlQOu333bW+gMNs2QREx7iynm19Abxw== dependencies: undici-types "~5.26.4" @@ -159,9 +159,9 @@ puppeteer "*" "@types/semver@^7.5.0": - version "7.5.5" - resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.5.tgz#deed5ab7019756c9c90ea86139106b0346223f35" - integrity sha512-+d+WYC1BxJ6yVOgUgzK8gWvp5qF8ssV5r4nsDcZWKRWcDQLQ619tvWAxJQYGgBrO1MnLJC7a5GtiYsAoQ47dJg== + version "7.5.6" + resolved "https://registry.yarnpkg.com/@types/semver/-/semver-7.5.6.tgz#c65b2bfce1bec346582c07724e3f8c1017a20339" + integrity sha512-dn1l8LaMea/IjDoHNd9J52uBbInB796CDffS6VdIxvqYCPSG0V0DzHp76GpaWnlhg88uYyPbXCDIowa86ybd5A== "@types/yauzl@^2.9.1": version "2.10.3" @@ -1144,10 +1144,12 @@ fill-range@^7.0.1: dependencies: to-regex-range "^5.0.1" -find-chrome-bin@1.0.5: - version "1.0.5" - resolved "https://registry.yarnpkg.com/find-chrome-bin/-/find-chrome-bin-1.0.5.tgz#45ba5c6599ece2ee9546e520475f29fd6f28d5c8" - integrity sha512-hz7lQfY012+IkiK4dJCp+kPCGurGLjbHhl9ngFeqr55ihS0eBhdKqCQamvHJvT59HSZB1tRORfMfRgTOpkLdxQ== +find-chrome-bin@2.0.0: + version "2.0.0" + resolved "https://registry.yarnpkg.com/find-chrome-bin/-/find-chrome-bin-2.0.0.tgz#c9d51e3aa929fe7530e369d3face39389c341e58" + integrity sha512-Uwsw1Orpl1wXW0GuafLhKGBrwqFTB0SPqru0vOvHMeO1xnP9pvdqlb1BP36kbcpXal2sZhcW10DEPT/U2DWL2w== + dependencies: + "@puppeteer/browsers" "^1.8.0" find-up@^5.0.0: version "5.0.0"