Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e955876a7c | |||
| b6472f38e2 | |||
| d4232decdd | |||
| 76999d8720 | |||
| 407ccf66b9 | |||
| 72e6ef04cb | |||
| d3732dcecc | |||
| a10b42270c |
123
.gitlab-ci.yml
123
.gitlab-ci.yml
@@ -7,10 +7,58 @@ cache:
|
||||
key: '$CI_BUILD_STAGE'
|
||||
|
||||
stages:
|
||||
- only
|
||||
- security
|
||||
- test
|
||||
- release
|
||||
- metadata
|
||||
|
||||
before_script:
|
||||
- npm install -g @shipzone/npmci
|
||||
|
||||
# ====================
|
||||
# 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
|
||||
allow_failure: true
|
||||
|
||||
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:
|
||||
stage: only
|
||||
stage: test
|
||||
script:
|
||||
- npmci npm prepare
|
||||
- npmci node install stable
|
||||
@@ -20,3 +68,74 @@ testStable:
|
||||
tags:
|
||||
- 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
|
||||
|
||||
23048
package-lock.json
generated
23048
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
23
package.json
23
package.json
@@ -1,30 +1,27 @@
|
||||
{
|
||||
"name": "@pushrocks/smartpuppeteer",
|
||||
"version": "1.0.35",
|
||||
"version": "2.0.2",
|
||||
"private": false,
|
||||
"description": "simplified access to puppeteer",
|
||||
"main": "dist_ts/index.js",
|
||||
"typings": "dist_ts/index.d.ts",
|
||||
"type": "module",
|
||||
"author": "Lossless GmbH",
|
||||
"license": "MIT",
|
||||
"scripts": {
|
||||
"test": "(tstest test/)",
|
||||
"build": "(tsbuild --web)",
|
||||
"format": "(gitzone format)"
|
||||
"test": "tstest test/",
|
||||
"build": "tsbuild --web --allowimplicitany"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.28",
|
||||
"@gitzone/tstest": "^1.0.59",
|
||||
"@pushrocks/tapbundle": "^3.2.14",
|
||||
"@types/node": "^16.11.6",
|
||||
"tslint": "^6.1.3",
|
||||
"tslint-config-prettier": "^1.15.0"
|
||||
"@gitzone/tsbuild": "^2.1.63",
|
||||
"@gitzone/tstest": "^1.0.71",
|
||||
"@pushrocks/tapbundle": "^5.0.3",
|
||||
"@types/node": "^18.0.6"
|
||||
},
|
||||
"dependencies": {
|
||||
"@pushrocks/smartdelay": "^2.0.13",
|
||||
"@pushrocks/smartenv": "^4.0.16",
|
||||
"@pushrocks/smartshell": "^2.0.29",
|
||||
"puppeteer": "^11.0.0",
|
||||
"@pushrocks/smartshell": "^2.0.30",
|
||||
"puppeteer": "^15.4.0",
|
||||
"tree-kill": "^1.2.2"
|
||||
},
|
||||
"files": [
|
||||
|
||||
21
test/test.ts
21
test/test.ts
@@ -1,11 +1,26 @@
|
||||
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('should use pipe', async (tools) => {
|
||||
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
|
||||
forceNoSandbox: true,
|
||||
forceNoSandbox: false,
|
||||
});
|
||||
const page = await headlessBrowser.newPage();
|
||||
await page.goto('https://lossless.com');
|
||||
console.log(await page.title());
|
||||
expect(headlessBrowser.wsEndpoint()).toEqual('');
|
||||
await headlessBrowser.close();
|
||||
});
|
||||
|
||||
tap.test('should use websocket', async (tools) => {
|
||||
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
|
||||
forceNoSandbox: false,
|
||||
usePipe: false,
|
||||
});
|
||||
const page = await headlessBrowser.newPage();
|
||||
await page.goto('https://lossless.com');
|
||||
console.log(await page.title());
|
||||
expect(headlessBrowser.wsEndpoint()).not.toEqual('');
|
||||
await headlessBrowser.close();
|
||||
});
|
||||
|
||||
|
||||
8
ts/00_commitinfo_data.ts
Normal file
8
ts/00_commitinfo_data.ts
Normal file
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* autocreated commitinfo by @pushrocks/commitinfo
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartpuppeteer',
|
||||
version: '2.0.2',
|
||||
description: 'simplified access to puppeteer'
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
// module exports
|
||||
|
||||
export * from './smartpuppeteer.classes.smartpuppeteer';
|
||||
export * from './smartpuppeteer.classes.incognitobrowser';
|
||||
export * from './smartpuppeteer.classes.smartpuppeteer.js';
|
||||
export * from './smartpuppeteer.classes.incognitobrowser.js';
|
||||
|
||||
// direct exports
|
||||
import { puppeteer } from './smartpuppeteer.plugins';
|
||||
import { puppeteer } from './smartpuppeteer.plugins.js';
|
||||
export { puppeteer };
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { getEnvAwareBrowserInstance } from './smartpuppeteer.classes.smartpuppeteer';
|
||||
import * as plugins from './smartpuppeteer.plugins';
|
||||
import { getEnvAwareBrowserInstance } from './smartpuppeteer.classes.smartpuppeteer.js';
|
||||
import * as plugins from './smartpuppeteer.plugins.js';
|
||||
|
||||
export class IncognitoBrowser {
|
||||
public status: 'started' | 'stopped' = 'stopped';
|
||||
@@ -28,7 +28,7 @@ export class IncognitoBrowser {
|
||||
*/
|
||||
public async stop() {
|
||||
this.status = 'stopped';
|
||||
plugins.treeKill(this.browser.process().pid, 'SIGKILL');
|
||||
plugins.treeKill(this.browser.process()?.pid as number, 'SIGKILL');
|
||||
await this.browser.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import * as plugins from './smartpuppeteer.plugins';
|
||||
import * as plugins from './smartpuppeteer.plugins.js';
|
||||
|
||||
export interface IEnvAwareOptions {
|
||||
forceNoSandbox?: boolean;
|
||||
usePipe?: boolean;
|
||||
}
|
||||
|
||||
export const getEnvAwareBrowserInstance = async (
|
||||
optionsArg: IEnvAwareOptions = {}
|
||||
): Promise<plugins.puppeteer.Browser> => {
|
||||
const smartenv = new plugins.smartenv.Smartenv();
|
||||
const options: IEnvAwareOptions = {
|
||||
...{
|
||||
forceNoSandbox: false,
|
||||
@@ -25,16 +25,16 @@ export const getEnvAwareBrowserInstance = async (
|
||||
console.log(chromeArgs);
|
||||
headlessBrowser = await plugins.puppeteer.launch({
|
||||
args: chromeArgs,
|
||||
pipe: true,
|
||||
pipe: options.usePipe !== undefined ? options.usePipe : true,
|
||||
headless: true,
|
||||
...(() => {
|
||||
const returnObject: any = {};
|
||||
const googleChrome = plugins.smartshell.which.sync('google-chrome')
|
||||
const googleChrome = plugins.smartshell.which.sync('google-chrome');
|
||||
if (googleChrome) {
|
||||
returnObject.executablePath = googleChrome
|
||||
returnObject.executablePath = googleChrome;
|
||||
}
|
||||
return returnObject;
|
||||
})()
|
||||
})(),
|
||||
});
|
||||
|
||||
return headlessBrowser;
|
||||
|
||||
@@ -5,10 +5,9 @@ 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, smartshell };
|
||||
export { smartdelay, smartshell };
|
||||
|
||||
// third party scope
|
||||
import puppeteer from 'puppeteer';
|
||||
|
||||
17
tslint.json
17
tslint.json
@@ -1,17 +0,0 @@
|
||||
{
|
||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
||||
"rules": {
|
||||
"semicolon": [true, "always"],
|
||||
"no-console": false,
|
||||
"ordered-imports": false,
|
||||
"object-literal-sort-keys": false,
|
||||
"member-ordering": {
|
||||
"options":{
|
||||
"order": [
|
||||
"static-method"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"defaultSeverity": "warning"
|
||||
}
|
||||
Reference in New Issue
Block a user