Compare commits

...

33 Commits

Author SHA1 Message Date
d94826a7b7 1.0.19 2021-01-08 21:53:18 +00:00
636f0580c6 fix(core): update 2021-01-08 21:53:17 +00:00
aa5552ce3a 1.0.18 2021-01-08 21:42:53 +00:00
3ef298215a fix(core): update 2021-01-08 21:42:52 +00:00
23c65e23ae 1.0.17 2021-01-08 21:16:26 +00:00
ef55253b8e fix(core): update 2021-01-08 21:16:25 +00:00
1b72af4702 1.0.16 2021-01-08 21:14:01 +00:00
44314c9894 fix(core): update 2021-01-08 21:14:01 +00:00
35129df11c 1.0.15 2020-02-25 01:38:24 +00:00
5dd6450347 fix(core): update 2020-02-25 01:38:24 +00:00
190d57bbe2 1.0.14 2019-11-16 17:51:13 +01:00
8d4519d615 fix(cli logs): now correctly stating when WSL is detected. 2019-11-16 17:51:11 +01:00
42a68434c0 1.0.13 2019-11-16 01:22:10 +01:00
35fd4678d1 fix(core): update 2019-11-16 01:22:08 +01:00
01a4122529 1.0.12 2019-11-16 01:15:10 +01:00
fbb94fe51e fix(core): update 2019-11-16 01:15:08 +01:00
656e21c8fd 1.0.11 2019-11-16 00:35:05 +01:00
53b5cca687 fix(core): update 2019-11-16 00:35:03 +01:00
25d191a95b 1.0.10 2019-11-16 00:01:07 +01:00
d5b3e48f8d fix(core): update 2019-11-16 00:01:05 +01:00
dd6f24551d 1.0.9 2019-11-15 23:59:35 +01:00
f4d0e9ad87 fix(core): update 2019-11-15 23:59:34 +01:00
41aefa7f18 1.0.8 2019-11-15 23:41:41 +01:00
c9f42b4c66 fix(core): update 2019-11-15 23:41:39 +01:00
0645364ca9 1.0.7 2019-11-15 21:44:13 +01:00
2d3f59cc65 fix(core): update 2019-11-15 21:44:11 +01:00
0e9c81b898 1.0.6 2019-11-15 18:59:29 +01:00
64cd7cd75d fix(core): update 2019-11-15 18:59:29 +01:00
f110320dae 1.0.5 2019-06-03 23:28:44 +02:00
cbc7fcb323 fix(core): update 2019-06-03 23:28:44 +02:00
0dc0e6ad53 1.0.4 2019-06-03 23:18:48 +02:00
a76d7439c4 1.0.3 2019-06-03 22:48:40 +02:00
df0b48cc47 fix(core): update 2019-06-03 22:48:40 +02:00
13 changed files with 10509 additions and 837 deletions

4
.gitignore vendored
View File

@@ -15,8 +15,6 @@ node_modules/
# builds
dist/
dist_web/
dist_serve/
dist_ts_web/
dist_*/
# custom

View File

@@ -1,16 +1,16 @@
# gitzone standard
image: hosttoday/ht-docker-node:npmci
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
- .npmci_cache/
key: "$CI_BUILD_STAGE"
- .npmci_cache/
key: '$CI_BUILD_STAGE'
stages:
- security
- test
- release
- metadata
- security
- test
- release
- metadata
# ====================
# security stage
@@ -18,102 +18,114 @@ stages:
mirror:
stage: security
script:
- npmci git mirror
- npmci git mirror
only:
- tags
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
snyk:
auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
- 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
- notpriv
- 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
# ====================
testLTS:
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testSTABLE:
- docker
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
- docker
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
- npmci node install stable
- npmci npm publish
only:
- tags
- tags
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
image: docker:stable
allow_failure: true
services:
- docker:stable-dind
only:
- tags
script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
- docker run
--env SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
- npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- docker
- priv
- lossless
- docker
- priv
trigger:
stage: metadata
script:
- npmci trigger
- npmci trigger
only:
- tags
- tags
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
pages:
image: hosttoday/ht-docker-node:npmci
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:
@@ -121,5 +133,5 @@ pages:
artifacts:
expire_in: 1 week
paths:
- public
- public
allow_failure: true

29
.vscode/launch.json vendored Normal file
View File

@@ -0,0 +1,29 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"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"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,26 @@
{
"json.schemas": [
{
"fileMatch": ["/npmextra.json"],
"schema": {
"type": "object",
"properties": {
"npmci": {
"type": "object",
"description": "settings for npmci"
},
"gitzone": {
"type": "object",
"description": "settings for gitzone",
"properties": {
"projectType": {
"type": "string",
"enum": ["website", "element", "service", "npm", "wcc"]
}
}
}
}
}
}
]
}

View File

@@ -1,5 +1,6 @@
{
"gitzone": {
"projectType": "npm",
"module": {
"githost": "gitlab.com",
"gitscope": "pushrocks",

10979
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,34 +1,44 @@
{
"name": "@pushrocks/smartpuppeteer",
"version": "1.0.2",
"version": "1.0.19",
"private": false,
"description": "simplified access to puppeteer",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"main": "dist_ts/index.js",
"typings": "dist_ts/index.d.ts",
"author": "Lossless GmbH",
"license": "MIT",
"scripts": {
"test": "(tstest test/)",
"build": "(tsbuild)",
"build": "(tsbuild --web)",
"format": "(gitzone format)"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.0.22",
"@gitzone/tstest": "^1.0.15",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^10.11.7",
"tslint": "^5.11.0",
"@gitzone/tsbuild": "^2.1.25",
"@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.2.9",
"@types/node": "^14.14.20",
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {},
"dependencies": {
"@pushrocks/smartdelay": "^2.0.10",
"@pushrocks/smartenv": "^4.0.16",
"@types/puppeteer": "^5.4.2",
"puppeteer": "^5.5.0"
},
"files": [
"ts/*",
"ts_web/*",
"dist/*",
"dist_web/*",
"assets/*",
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}

View File

@@ -8,19 +8,39 @@ simplified access to puppeteer
* [docs (typedoc)](https://pushrocks.gitlab.io/smartpuppeteer/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartpuppeteer/badges/master/build.svg)](https://gitlab.com/pushrocks/smartpuppeteer/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartpuppeteer/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartpuppeteer/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartpuppeteer.svg)](https://www.npmjs.com/package/@pushrocks/smartpuppeteer)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartpuppeteer/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartpuppeteer)
[![TypeScript](https://img.shields.io/badge/TypeScript->=%203.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-prettier-ff69b4.svg)](https://prettier.io/)
Status Category | Status Badge
-- | --
GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartpuppeteer/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartpuppeteer/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartpuppeteer)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartpuppeteer)](https://lossless.cloud)
TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud)
node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/)
Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud)
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartpuppeteer)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartpuppeteer)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartpuppeteer)](https://lossless.cloud)
Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud)
## Usage
Use TypeScript for best in class intellisense.
```typescript
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
forceNoSandbox: true, // if you really want no sandbox, you can do this. Otherwise its starting things as necessary
});
await headlessBrowser.close();
```
## Contribution
We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :)
For further information read the linked docs at the top of this readme.
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@@ -1,8 +1,11 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as smartpuppeteer from '../ts/index';
tap.test('first test', async () => {
console.log(smartpuppeteer.standardExport);
tap.test('first test', async (tools) => {
const headlessBrowser = await smartpuppeteer.getEnvAwareBrowserInstance({
forceNoSandbox: true,
});
await headlessBrowser.close();
});
tap.start();

View File

@@ -1,3 +1,8 @@
import * as plugins from './smartpuppeteer.plugins';
// module exports
export let standardExport = 'Hi there! :) This is an exported string';
export * from './smartpuppeteer.classes.smartpuppeteer';
export * from './smartpuppeteer.classes.incognitobrowser';
// direct exports
import { puppeteer } from './smartpuppeteer.plugins';
export { puppeteer };

View File

@@ -0,0 +1,41 @@
import { getEnvAwareBrowserInstance } from './smartpuppeteer.classes.smartpuppeteer';
import * as plugins from './smartpuppeteer.plugins';
export class IncognitoBrowser {
public status: 'started' | 'stopped' = 'stopped';
public browser: plugins.puppeteer.Browser;
constructor() {}
/**
* starts the IncognitoBrowser
*/
public async start() {
this.status = 'started';
this.browser = await getEnvAwareBrowserInstance();
this.browser.addListener('disconnected', async (eventArg) => {
try {
this.browser.removeAllListeners();
} catch (err) {}
if (this.status === 'started') {
this.browser = await getEnvAwareBrowserInstance();
}
});
}
/**
* stops the IncognitoBrowser
*/
public async stop() {
this.status = 'stopped';
await this.browser.close();
}
public async getNewIncognitoContext(): Promise<plugins.puppeteer.BrowserContext> {
if (this.browser) {
return this.browser.createIncognitoBrowserContext();
} else {
throw new Error('you need to start the IncognitoBrowser instance first');
}
}
}

View File

@@ -0,0 +1,31 @@
import * as plugins from './smartpuppeteer.plugins';
export interface IEnvAwareOptions {
forceNoSandbox?: boolean;
}
export const getEnvAwareBrowserInstance = async (
optionsArg: IEnvAwareOptions = {}
): Promise<plugins.puppeteer.Browser> => {
const smartenv = new plugins.smartenv.Smartenv();
const options: IEnvAwareOptions = {
...{
forceNoSandbox: false,
},
...optionsArg,
};
let chromeArgs: string[] = [];
if (process.env.CI || options.forceNoSandbox || plugins.os.userInfo().username === 'root') {
chromeArgs = chromeArgs.concat(['--no-sandbox', '--disable-setuid-sandbox']);
}
let headlessBrowser: plugins.puppeteer.Browser;
console.log('launching puppeteer bundled chrome with arguments:');
console.log(chromeArgs);
headlessBrowser = await plugins.puppeteer.launch({
args: chromeArgs,
});
return headlessBrowser;
};

View File

@@ -1,2 +1,15 @@
const removeme = {};
export { removeme };
// node native scope
import * as os from 'os';
export { os };
// @pushrocks scope
import * as smartdelay from '@pushrocks/smartdelay';
import * as smartenv from '@pushrocks/smartenv';
export { smartdelay, smartenv };
// third party scope
import puppeteer from 'puppeteer';
export { puppeteer };