Compare commits

...

29 Commits

Author SHA1 Message Date
407ccf66b9 2.0.0 2022-03-24 13:51:13 +01:00
72e6ef04cb BREAKING CHANGE(core): switch to esm 2022-03-24 13:51:12 +01:00
d3732dcecc 1.0.36 2021-11-07 19:51:50 +01:00
a10b42270c fix(core): update 2021-11-07 19:51:50 +01:00
b2efe28f4d 1.0.35 2021-11-07 19:33:10 +01:00
1ab34d909b fix(core): update 2021-11-07 19:33:09 +01:00
09a8888d47 1.0.34 2021-11-07 18:55:11 +01:00
243beb2c75 1.0.33 2021-11-07 18:50:23 +01:00
c6fd1bea7a fix(core): update 2021-11-07 18:50:22 +01:00
4f94fa31ac 1.0.32 2021-11-07 18:38:16 +01:00
ac61d8ff4d fix(core): update 2021-11-07 18:38:15 +01:00
107178e9e7 1.0.31 2021-11-07 18:33:26 +01:00
0b5c030d5d fix(core): update 2021-11-07 18:33:25 +01:00
94f145c3dc 1.0.30 2021-11-07 18:30:09 +01:00
ebd60756ea fix(core): update 2021-11-07 18:30:08 +01:00
8305dd105c 1.0.29 2021-11-07 15:58:45 +01:00
797cac672b fix(core): update 2021-11-07 15:58:45 +01:00
4b1f058a21 1.0.28 2021-11-07 15:46:31 +01:00
c38f338f8e 1.0.27 2021-08-17 17:51:50 +02:00
103c7eb11e fix(core): update 2021-08-17 17:51:50 +02:00
0190f1bb77 1.0.26 2021-08-17 15:22:10 +02:00
87d7460183 fix(core): update 2021-08-17 15:22:10 +02:00
ed1522062e 1.0.25 2021-08-17 12:20:54 +02:00
116f700d5c fix(core): update 2021-08-17 12:20:54 +02:00
366a033904 1.0.24 2021-08-17 02:53:34 +02:00
5f1f4b3c53 fix(core): update 2021-08-17 02:53:34 +02:00
255bd7046e 1.0.23 2021-08-17 02:51:24 +02:00
bb82845f27 1.0.22 2021-08-17 02:50:49 +02:00
8ec23ba414 fix(core): update 2021-08-17 02:50:49 +02:00
9 changed files with 15673 additions and 7549 deletions

View File

@@ -12,6 +12,9 @@ stages:
- release - release
- metadata - metadata
before_script:
- npm install -g @shipzone/npmci
# ==================== # ====================
# security stage # security stage
# ==================== # ====================
@@ -36,6 +39,7 @@ auditProductionDependencies:
- npmci command npm audit --audit-level=high --only=prod --production - npmci command npm audit --audit-level=high --only=prod --production
tags: tags:
- docker - docker
allow_failure: true
auditDevDependencies: auditDevDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci

24
.vscode/launch.json vendored
View File

@@ -2,28 +2,10 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "current file", "command": "npm test",
"type": "node", "name": "Run npm test",
"request": "launch", "request": "launch",
"args": [ "type": "node-terminal"
"${relativeFile}"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "test.ts",
"type": "node",
"request": "launch",
"args": [
"test/test.ts"
],
"runtimeArgs": ["-r", "@gitzone/tsrun"],
"cwd": "${workspaceRoot}",
"protocol": "inspector",
"internalConsoleOptions": "openOnSessionStart"
} }
] ]
} }

23124
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,30 +1,30 @@
{ {
"name": "@pushrocks/smartpuppeteer", "name": "@pushrocks/smartpuppeteer",
"version": "1.0.21", "version": "2.0.0",
"private": false, "private": false,
"description": "simplified access to puppeteer", "description": "simplified access to puppeteer",
"main": "dist_ts/index.js", "main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts", "typings": "dist_ts/index.d.ts",
"type": "module",
"author": "Lossless GmbH", "author": "Lossless GmbH",
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "tstest test/",
"build": "(tsbuild --web)", "build": "tsbuild --web --allowimplicitany"
"format": "(gitzone format)"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.25", "@gitzone/tsbuild": "^2.1.60",
"@gitzone/tstest": "^1.0.52", "@gitzone/tstest": "^1.0.69",
"@pushrocks/tapbundle": "^3.2.9", "@pushrocks/tapbundle": "^5.0.3",
"@types/node": "^14.14.20", "@types/node": "^17.0.23",
"tslint": "^6.1.3", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0" "tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartdelay": "^2.0.10", "@pushrocks/smartdelay": "^2.0.13",
"@pushrocks/smartenv": "^4.0.16", "@pushrocks/smartshell": "^2.0.30",
"@types/puppeteer": "^5.4.2", "puppeteer": "^13.5.1",
"puppeteer": "^5.5.0" "tree-kill": "^1.2.2"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",

View File

@@ -1,11 +1,19 @@
import { expect, tap } from '@pushrocks/tapbundle'; import { expect, tap } from '@pushrocks/tapbundle';
import * as smartpuppeteer from '../ts/index'; import * as smartpuppeteer from '../ts/index.js';
tap.test('first test', async (tools) => { tap.test('first test', async (tools) => {
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({ const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
forceNoSandbox: true, forceNoSandbox: true,
}); });
const page = await headlessBrowser.newPage();
await headlessBrowser.close(); await headlessBrowser.close();
}); });
tap.test('should get and stop an Incognito browser', async () => {
const incognitoInstance = new smartpuppeteer.IncognitoBrowser();
await incognitoInstance.start();
const page = await incognitoInstance.browser.newPage();
await incognitoInstance.stop();
});
tap.start(); tap.start();

View File

@@ -1,8 +1,8 @@
// module exports // module exports
export * from './smartpuppeteer.classes.smartpuppeteer'; export * from './smartpuppeteer.classes.smartpuppeteer.js';
export * from './smartpuppeteer.classes.incognitobrowser'; export * from './smartpuppeteer.classes.incognitobrowser.js';
// direct exports // direct exports
import { puppeteer } from './smartpuppeteer.plugins'; import { puppeteer } from './smartpuppeteer.plugins.js';
export { puppeteer }; export { puppeteer };

View File

@@ -1,5 +1,5 @@
import { getEnvAwareBrowserInstance } from './smartpuppeteer.classes.smartpuppeteer'; import { getEnvAwareBrowserInstance } from './smartpuppeteer.classes.smartpuppeteer.js';
import * as plugins from './smartpuppeteer.plugins'; import * as plugins from './smartpuppeteer.plugins.js';
export class IncognitoBrowser { export class IncognitoBrowser {
public status: 'started' | 'stopped' = 'stopped'; public status: 'started' | 'stopped' = 'stopped';
@@ -13,7 +13,7 @@ export class IncognitoBrowser {
public async start() { public async start() {
this.status = 'started'; this.status = 'started';
this.browser = await getEnvAwareBrowserInstance(); this.browser = await getEnvAwareBrowserInstance();
this.browser.addListener('disconnected', async (eventArg) => { this.browser.on('disconnected', async (eventArg) => {
try { try {
this.browser.removeAllListeners(); this.browser.removeAllListeners();
} catch (err) {} } catch (err) {}
@@ -28,13 +28,14 @@ export class IncognitoBrowser {
*/ */
public async stop() { public async stop() {
this.status = 'stopped'; this.status = 'stopped';
plugins.treeKill(this.browser.process().pid, 'SIGKILL');
await this.browser.close(); await this.browser.close();
} }
/** /**
* rotate * rotate
*/ */
public async rotateBrowser () { public async rotateBrowser() {
this.browser.close().catch(); this.browser.close().catch();
this.browser = await getEnvAwareBrowserInstance(); this.browser = await getEnvAwareBrowserInstance();
} }

View File

@@ -1,4 +1,4 @@
import * as plugins from './smartpuppeteer.plugins'; import * as plugins from './smartpuppeteer.plugins.js';
export interface IEnvAwareOptions { export interface IEnvAwareOptions {
forceNoSandbox?: boolean; forceNoSandbox?: boolean;
@@ -7,7 +7,6 @@ export interface IEnvAwareOptions {
export const getEnvAwareBrowserInstance = async ( export const getEnvAwareBrowserInstance = async (
optionsArg: IEnvAwareOptions = {} optionsArg: IEnvAwareOptions = {}
): Promise<plugins.puppeteer.Browser> => { ): Promise<plugins.puppeteer.Browser> => {
const smartenv = new plugins.smartenv.Smartenv();
const options: IEnvAwareOptions = { const options: IEnvAwareOptions = {
...{ ...{
forceNoSandbox: false, forceNoSandbox: false,
@@ -25,7 +24,16 @@ export const getEnvAwareBrowserInstance = async (
console.log(chromeArgs); console.log(chromeArgs);
headlessBrowser = await plugins.puppeteer.launch({ headlessBrowser = await plugins.puppeteer.launch({
args: chromeArgs, args: chromeArgs,
pipe: true pipe: true,
headless: true,
...(() => {
const returnObject: any = {};
const googleChrome = plugins.smartshell.which.sync('google-chrome');
if (googleChrome) {
returnObject.executablePath = googleChrome;
}
return returnObject;
})(),
}); });
return headlessBrowser; return headlessBrowser;

View File

@@ -5,11 +5,12 @@ export { os };
// @pushrocks scope // @pushrocks scope
import * as smartdelay from '@pushrocks/smartdelay'; import * as smartdelay from '@pushrocks/smartdelay';
import * as smartenv from '@pushrocks/smartenv'; import * as smartshell from '@pushrocks/smartshell';
export { smartdelay, smartenv }; export { smartdelay, smartshell };
// third party scope // third party scope
import puppeteer from 'puppeteer'; import puppeteer from 'puppeteer';
import treeKill from 'tree-kill';
export { puppeteer }; export { puppeteer, treeKill };