Compare commits
15 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 57776a67b3 | |||
| 8809b9755b | |||
| 1138897da2 | |||
| 831f967960 | |||
| fc602235cf | |||
| 775f2bde13 | |||
| 3c436b7167 | |||
| 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'
|
key: '$CI_BUILD_STAGE'
|
||||||
|
|
||||||
stages:
|
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:
|
testStable:
|
||||||
stage: only
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install stable
|
- npmci node install stable
|
||||||
@@ -20,3 +68,74 @@ 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 @git.zone/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
|
||||||
|
|||||||
@@ -2,11 +2,11 @@
|
|||||||
"gitzone": {
|
"gitzone": {
|
||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.com",
|
"githost": "code.foss.global",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "push.rocks",
|
||||||
"gitrepo": "smartpuppeteer",
|
"gitrepo": "smartpuppeteer",
|
||||||
"shortDescription": "simplified access to puppeteer",
|
"shortDescription": "simplified access to puppeteer",
|
||||||
"npmPackagename": "@pushrocks/smartpuppeteer",
|
"npmPackagename": "@push.rocks/smartpuppeteer",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"projectDomain": "push.rocks"
|
"projectDomain": "push.rocks"
|
||||||
}
|
}
|
||||||
@@ -14,5 +14,8 @@
|
|||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"tsdocs": {
|
||||||
|
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
23496
package-lock.json
generated
23496
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
28
package.json
28
package.json
@@ -1,30 +1,28 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartpuppeteer",
|
"name": "@push.rocks/smartpuppeteer",
|
||||||
"version": "1.0.35",
|
"version": "2.0.3",
|
||||||
"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.28",
|
"@git.zone/tsbuild": "^2.1.63",
|
||||||
"@gitzone/tstest": "^1.0.59",
|
"@git.zone/tsrun": "^1.2.46",
|
||||||
"@pushrocks/tapbundle": "^3.2.14",
|
"@git.zone/tstest": "^1.0.71",
|
||||||
"@types/node": "^16.11.6",
|
"@push.rocks/tapbundle": "^5.0.8",
|
||||||
"tslint": "^6.1.3",
|
"@types/node": "^20.12.7"
|
||||||
"tslint-config-prettier": "^1.15.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartdelay": "^2.0.13",
|
"@push.rocks/smartdelay": "^3.0.1",
|
||||||
"@pushrocks/smartenv": "^4.0.16",
|
"@push.rocks/smartshell": "^3.0.3",
|
||||||
"@pushrocks/smartshell": "^2.0.29",
|
"puppeteer": "^22.6.4",
|
||||||
"puppeteer": "^11.0.0",
|
|
||||||
"tree-kill": "^1.2.2"
|
"tree-kill": "^1.2.2"
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
|
|||||||
5135
pnpm-lock.yaml
generated
Normal file
5135
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
12
readme.md
12
readme.md
@@ -1,8 +1,8 @@
|
|||||||
# @pushrocks/smartpuppeteer
|
# @push.rocks/smartpuppeteer
|
||||||
simplified access to puppeteer
|
simplified access to puppeteer
|
||||||
|
|
||||||
## Availabililty and Links
|
## Availabililty and Links
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartpuppeteer)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@push.rocks/smartpuppeteer)
|
||||||
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartpuppeteer)
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartpuppeteer)
|
||||||
* [github.com (source mirror)](https://github.com/pushrocks/smartpuppeteer)
|
* [github.com (source mirror)](https://github.com/pushrocks/smartpuppeteer)
|
||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartpuppeteer/)
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartpuppeteer/)
|
||||||
@@ -13,14 +13,14 @@ Status Category | Status Badge
|
|||||||
-- | --
|
-- | --
|
||||||
GitLab Pipelines | [](https://lossless.cloud)
|
GitLab Pipelines | [](https://lossless.cloud)
|
||||||
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
GitLab Pipline Test Coverage | [](https://lossless.cloud)
|
||||||
npm | [](https://lossless.cloud)
|
npm | [](https://lossless.cloud)
|
||||||
Snyk | [](https://lossless.cloud)
|
Snyk | [](https://lossless.cloud)
|
||||||
TypeScript Support | [](https://lossless.cloud)
|
TypeScript Support | [](https://lossless.cloud)
|
||||||
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
node Support | [](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
Code Style | [](https://lossless.cloud)
|
Code Style | [](https://lossless.cloud)
|
||||||
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
PackagePhobia (total standalone install weight) | [](https://lossless.cloud)
|
||||||
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
PackagePhobia (package size on registry) | [](https://lossless.cloud)
|
||||||
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
BundlePhobia (total size when bundled) | [](https://lossless.cloud)
|
||||||
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
Platform support | [](https://lossless.cloud) [](https://lossless.cloud)
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|||||||
23
test/test.ts
23
test/test.ts
@@ -1,11 +1,26 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@push.rocks/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({
|
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
|
||||||
forceNoSandbox: true,
|
forceNoSandbox: false,
|
||||||
});
|
});
|
||||||
const page = await headlessBrowser.newPage();
|
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();
|
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: '@push.rocks/smartpuppeteer',
|
||||||
|
version: '2.0.3',
|
||||||
|
description: 'simplified access to puppeteer'
|
||||||
|
}
|
||||||
@@ -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 };
|
||||||
|
|||||||
@@ -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';
|
||||||
@@ -28,7 +28,7 @@ export class IncognitoBrowser {
|
|||||||
*/
|
*/
|
||||||
public async stop() {
|
public async stop() {
|
||||||
this.status = 'stopped';
|
this.status = 'stopped';
|
||||||
plugins.treeKill(this.browser.process().pid, 'SIGKILL');
|
plugins.treeKill(this.browser.process()?.pid as number, 'SIGKILL');
|
||||||
await this.browser.close();
|
await this.browser.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import * as plugins from './smartpuppeteer.plugins';
|
import * as plugins from './smartpuppeteer.plugins.js';
|
||||||
|
|
||||||
export interface IEnvAwareOptions {
|
export interface IEnvAwareOptions {
|
||||||
forceNoSandbox?: boolean;
|
forceNoSandbox?: boolean;
|
||||||
|
usePipe?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
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,16 +25,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: options.usePipe !== undefined ? options.usePipe : true,
|
||||||
headless: true,
|
headless: true,
|
||||||
...(() => {
|
...(() => {
|
||||||
const returnObject: any = {};
|
const returnObject: any = {};
|
||||||
const googleChrome = plugins.smartshell.which.sync('google-chrome')
|
const googleChrome = plugins.smartshell.which.sync('google-chrome');
|
||||||
if(googleChrome) {
|
if (googleChrome) {
|
||||||
returnObject.executablePath = googleChrome
|
returnObject.executablePath = googleChrome;
|
||||||
}
|
}
|
||||||
return returnObject;
|
return returnObject;
|
||||||
})()
|
})(),
|
||||||
});
|
});
|
||||||
|
|
||||||
return headlessBrowser;
|
return headlessBrowser;
|
||||||
|
|||||||
@@ -4,11 +4,10 @@ import * as os from 'os';
|
|||||||
export { os };
|
export { os };
|
||||||
|
|
||||||
// @pushrocks scope
|
// @pushrocks scope
|
||||||
import * as smartdelay from '@pushrocks/smartdelay';
|
import * as smartdelay from '@push.rocks/smartdelay';
|
||||||
import * as smartenv from '@pushrocks/smartenv';
|
import * as smartshell from '@push.rocks/smartshell';
|
||||||
import * as smartshell from '@pushrocks/smartshell';
|
|
||||||
|
|
||||||
export { smartdelay, smartenv, smartshell };
|
export { smartdelay, smartshell };
|
||||||
|
|
||||||
// third party scope
|
// third party scope
|
||||||
import puppeteer from 'puppeteer';
|
import puppeteer from 'puppeteer';
|
||||||
|
|||||||
14
tsconfig.json
Normal file
14
tsconfig.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist_*/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
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