Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d3732dcecc | |||
| a10b42270c | |||
| b2efe28f4d | |||
| 1ab34d909b | |||
| 09a8888d47 | |||
| 243beb2c75 | |||
| c6fd1bea7a | |||
| 4f94fa31ac | |||
| ac61d8ff4d | |||
| 107178e9e7 | |||
| 0b5c030d5d | |||
| 94f145c3dc | |||
| ebd60756ea | |||
| 8305dd105c | |||
| 797cac672b | |||
| 4b1f058a21 | |||
| c38f338f8e | |||
| 103c7eb11e | |||
| 0190f1bb77 | |||
| 87d7460183 | |||
| ed1522062e | |||
| 116f700d5c |
@@ -12,6 +12,9 @@ stages:
|
||||
- release
|
||||
- metadata
|
||||
|
||||
before_script:
|
||||
- npm install -g @shipzone/npmci
|
||||
|
||||
# ====================
|
||||
# security stage
|
||||
# ====================
|
||||
@@ -36,6 +39,7 @@ auditProductionDependencies:
|
||||
- npmci command npm audit --audit-level=high --only=prod --production
|
||||
tags:
|
||||
- docker
|
||||
allow_failure: true
|
||||
|
||||
auditDevDependencies:
|
||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||
|
||||
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@@ -2,28 +2,10 @@
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "current file",
|
||||
"type": "node",
|
||||
"command": "npm test",
|
||||
"name": "Run npm test",
|
||||
"request": "launch",
|
||||
"args": [
|
||||
"${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"
|
||||
"type": "node-terminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
9660
package-lock.json
generated
9660
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
13
package.json
13
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartpuppeteer",
|
||||
"version": "1.0.24",
|
||||
"version": "1.0.36",
|
||||
"private": false,
|
||||
"description": "simplified access to puppeteer",
|
||||
"main": "dist_ts/index.js",
|
||||
@@ -13,18 +13,19 @@
|
||||
"format": "(gitzone format)"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tstest": "^1.0.54",
|
||||
"@gitzone/tsbuild": "^2.1.28",
|
||||
"@gitzone/tstest": "^1.0.59",
|
||||
"@pushrocks/tapbundle": "^3.2.14",
|
||||
"@types/node": "^16.6.1",
|
||||
"@types/node": "^16.11.6",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
"@pushrocks/smartenv": "^4.0.16",
|
||||
"@types/puppeteer": "^5.4.4",
|
||||
"puppeteer": "^10.2.0"
|
||||
"@pushrocks/smartshell": "^2.0.29",
|
||||
"puppeteer": "^11.0.0",
|
||||
"tree-kill": "^1.2.2"
|
||||
},
|
||||
"files": [
|
||||
"ts/**/*",
|
||||
|
||||
@@ -5,7 +5,15 @@ tap.test('first test', async (tools) => {
|
||||
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
|
||||
forceNoSandbox: true,
|
||||
});
|
||||
const page = await headlessBrowser.newPage();
|
||||
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();
|
||||
|
||||
@@ -28,13 +28,14 @@ export class IncognitoBrowser {
|
||||
*/
|
||||
public async stop() {
|
||||
this.status = 'stopped';
|
||||
plugins.treeKill(this.browser.process().pid, 'SIGKILL');
|
||||
await this.browser.close();
|
||||
}
|
||||
|
||||
/**
|
||||
* rotate
|
||||
*/
|
||||
public async rotateBrowser () {
|
||||
public async rotateBrowser() {
|
||||
this.browser.close().catch();
|
||||
this.browser = await getEnvAwareBrowserInstance();
|
||||
}
|
||||
|
||||
@@ -25,7 +25,16 @@ export const getEnvAwareBrowserInstance = async (
|
||||
console.log(chromeArgs);
|
||||
headlessBrowser = await plugins.puppeteer.launch({
|
||||
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;
|
||||
|
||||
@@ -6,10 +6,12 @@ export { os };
|
||||
// @pushrocks scope
|
||||
import * as smartdelay from '@pushrocks/smartdelay';
|
||||
import * as smartenv from '@pushrocks/smartenv';
|
||||
import * as smartshell from '@pushrocks/smartshell';
|
||||
|
||||
export { smartdelay, smartenv };
|
||||
export { smartdelay, smartenv, smartshell };
|
||||
|
||||
// third party scope
|
||||
import puppeteer from 'puppeteer';
|
||||
import treeKill from 'tree-kill';
|
||||
|
||||
export { puppeteer };
|
||||
export { puppeteer, treeKill };
|
||||
|
||||
Reference in New Issue
Block a user