Compare commits
22 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 107178e9e7 | |||
| 0b5c030d5d | |||
| 94f145c3dc | |||
| ebd60756ea | |||
| 8305dd105c | |||
| 797cac672b | |||
| 4b1f058a21 | |||
| c38f338f8e | |||
| 103c7eb11e | |||
| 0190f1bb77 | |||
| 87d7460183 | |||
| ed1522062e | |||
| 116f700d5c | |||
| 366a033904 | |||
| 5f1f4b3c53 | |||
| 255bd7046e | |||
| bb82845f27 | |||
| 8ec23ba414 | |||
| 937605f8c1 | |||
| f05c2226c5 | |||
| 1d2eca0991 | |||
| c91f77a0d4 |
120
.gitlab-ci.yml
120
.gitlab-ci.yml
@@ -7,55 +7,12 @@ cache:
|
|||||||
key: '$CI_BUILD_STAGE'
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
stages:
|
stages:
|
||||||
- security
|
- only
|
||||||
- test
|
|
||||||
- release
|
|
||||||
- metadata
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# security stage
|
|
||||||
# ====================
|
|
||||||
mirror:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci git mirror
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
auditProductionDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --production --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high --only=prod --production
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
auditDevDependencies:
|
|
||||||
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install --ignore-scripts
|
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
|
||||||
- npmci command npm audit --audit-level=high --only=dev
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# test stage
|
|
||||||
# ====================
|
|
||||||
|
|
||||||
testStable:
|
testStable:
|
||||||
stage: test
|
stage: only
|
||||||
script:
|
script:
|
||||||
|
- whereis google-chrome
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
@@ -64,74 +21,3 @@ testStable:
|
|||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
|
|
||||||
testBuild:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command npm run build
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
script:
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm publish
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# metadata stage
|
|
||||||
# ====================
|
|
||||||
codequality:
|
|
||||||
stage: metadata
|
|
||||||
allow_failure: true
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
script:
|
|
||||||
- npmci command npm install -g tslint typescript
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci trigger
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
pages:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command tsdoc
|
|
||||||
tags:
|
|
||||||
- lossless
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
||||||
allow_failure: true
|
|
||||||
|
|||||||
24
.vscode/launch.json
vendored
24
.vscode/launch.json
vendored
@@ -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"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|||||||
22486
package-lock.json
generated
22486
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
16
package.json
16
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartpuppeteer",
|
"name": "@pushrocks/smartpuppeteer",
|
||||||
"version": "1.0.19",
|
"version": "1.0.31",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "simplified access to puppeteer",
|
"description": "simplified access to puppeteer",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@@ -13,18 +13,18 @@
|
|||||||
"format": "(gitzone format)"
|
"format": "(gitzone format)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.28",
|
||||||
"@gitzone/tstest": "^1.0.52",
|
"@gitzone/tstest": "^1.0.59",
|
||||||
"@pushrocks/tapbundle": "^3.2.9",
|
"@pushrocks/tapbundle": "^3.2.14",
|
||||||
"@types/node": "^14.14.20",
|
"@types/node": "^16.11.6",
|
||||||
"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/smartenv": "^4.0.16",
|
||||||
"@types/puppeteer": "^5.4.2",
|
"puppeteer": "^11.0.0",
|
||||||
"puppeteer": "^5.5.0"
|
"tree-kill": "^1.2.2"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
|
|||||||
@@ -5,7 +5,15 @@ 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();
|
||||||
|
|||||||
@@ -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,9 +28,18 @@ 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
|
||||||
|
*/
|
||||||
|
public async rotateBrowser() {
|
||||||
|
this.browser.close().catch();
|
||||||
|
this.browser = await getEnvAwareBrowserInstance();
|
||||||
|
}
|
||||||
|
|
||||||
public async getNewIncognitoContext(): Promise<plugins.puppeteer.BrowserContext> {
|
public async getNewIncognitoContext(): Promise<plugins.puppeteer.BrowserContext> {
|
||||||
if (this.browser) {
|
if (this.browser) {
|
||||||
return this.browser.createIncognitoBrowserContext();
|
return this.browser.createIncognitoBrowserContext();
|
||||||
|
|||||||
@@ -25,6 +25,9 @@ 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,
|
||||||
|
headless: true,
|
||||||
|
executablePath: '/bin/chrome'
|
||||||
});
|
});
|
||||||
|
|
||||||
return headlessBrowser;
|
return headlessBrowser;
|
||||||
|
|||||||
@@ -11,5 +11,6 @@ export { smartdelay, smartenv };
|
|||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
import puppeteer from 'puppeteer';
|
import puppeteer from 'puppeteer';
|
||||||
|
import treeKill from 'tree-kill';
|
||||||
|
|
||||||
export { puppeteer };
|
export { puppeteer, treeKill };
|
||||||
|
|||||||
Reference in New Issue
Block a user