fix(core): update

This commit is contained in:
Philipp Kunz 2020-06-01 20:19:25 +00:00
parent 2e95f1db7f
commit 4ee936035c
10 changed files with 3024 additions and 1022 deletions

4
.gitignore vendored
View File

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

View File

@ -1,16 +1,16 @@
# gitzone standard # gitzone ci_default
image: hosttoday/ht-docker-node:npmci image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache: cache:
paths: paths:
- .npmci_cache/ - .npmci_cache/
key: "$CI_BUILD_STAGE" key: '$CI_BUILD_STAGE'
stages: stages:
- security - security
- test - test
- release - release
- metadata - metadata
# ==================== # ====================
# security stage # security stage
@ -20,17 +20,20 @@ mirror:
script: script:
- npmci git mirror - npmci git mirror
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
snyk: audit:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security stage: security
script: script:
- npmci npm prepare - npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts - npmci command npm install --ignore-scripts
- npmci command snyk test - npmci command npm config set registry https://registry.npmjs.org
- npmci command npm audit --audit-level=high
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
@ -38,19 +41,7 @@ snyk:
# test stage # test stage
# ==================== # ====================
testLTS: testStable:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
testSTABLE:
stage: test stage: test
script: script:
- npmci npm prepare - npmci npm prepare
@ -59,6 +50,20 @@ testSTABLE:
- npmci npm test - npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- lossless
- docker
- priv
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:
- lossless
- docker - docker
- notpriv - notpriv
@ -70,6 +75,7 @@ release:
only: only:
- tags - tags
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
@ -78,20 +84,14 @@ release:
# ==================== # ====================
codequality: codequality:
stage: metadata stage: metadata
image: docker:stable
allow_failure: true allow_failure: true
services:
- docker:stable-dind
script: script:
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/') - npmci command npm install -g tslint typescript
- docker run - npmci npm prepare
--env SOURCE_CODE="$PWD" - npmci npm install
--volume "$PWD":/code - npmci command "tslint -c tslint.json ./ts/**/*.ts"
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
tags: tags:
- lossless
- docker - docker
- priv - priv
@ -102,18 +102,20 @@ trigger:
only: only:
- tags - tags
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
pages: pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata stage: metadata
script: script:
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc - npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command tsdoc - npmci command tsdoc
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
only: only:

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"]
}
}
}
}
}
}
]
}

View File

@ -1,28 +0,0 @@
# @pushrocks/smartbrowser
puppeteer wrapper for easy tasks
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartbrowser)
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartbrowser)
* [github.com (source mirror)](https://github.com/pushrocks/smartbrowser)
* [docs (typedoc)](https://pushrocks.gitlab.io/smartbrowser/)
## Status for master
[![build status](https://gitlab.com/pushrocks/smartbrowser/badges/master/build.svg)](https://gitlab.com/pushrocks/smartbrowser/commits/master)
[![coverage report](https://gitlab.com/pushrocks/smartbrowser/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartbrowser/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartbrowser.svg)](https://www.npmjs.com/package/@pushrocks/smartbrowser)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartbrowser/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartbrowser)
[![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/)
## Usage
Use TypeScript for best in class instellisense.
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)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

View File

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

3790
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,11 +2,11 @@
"name": "@pushrocks/smartbrowser", "name": "@pushrocks/smartbrowser",
"version": "1.0.14", "version": "1.0.14",
"description": "simplified puppeteer", "description": "simplified puppeteer",
"main": "dist/index.js", "main": "dist_ts/index.js",
"typings": "dist/index.d.ts", "typings": "dist_ts/index.d.ts",
"scripts": { "scripts": {
"test": "tstest test/", "test": "(tstest test/ --web)",
"build": "tsbuild" "build": "(tsbuild --web)"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@ -19,25 +19,27 @@
}, },
"homepage": "https://gitlab.com/pushrocks/smartbrowser#README", "homepage": "https://gitlab.com/pushrocks/smartbrowser#README",
"dependencies": { "dependencies": {
"@pushrocks/smartdelay": "^2.0.3", "@pushrocks/smartdelay": "^2.0.9",
"@pushrocks/smartpdf": "^1.0.17", "@pushrocks/smartpdf": "^2.0.2",
"@pushrocks/smartpuppeteer": "^1.0.5", "@pushrocks/smartpuppeteer": "^1.0.15",
"@pushrocks/smartunique": "^3.0.1" "@pushrocks/smartunique": "^3.0.3"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.11", "@gitzone/tsbuild": "^2.1.24",
"@gitzone/tstest": "^1.0.24", "@gitzone/tstest": "^1.0.32",
"@pushrocks/tapbundle": "^3.0.9", "@pushrocks/tapbundle": "^3.2.1",
"tslint": "^5.17.0", "tslint": "^6.1.2",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"private": true, "private": true,
"files": [ "files": [
"ts/*", "ts/**/*",
"ts_web/*", "ts_web/**/*",
"dist/*", "dist/**/*",
"dist_web/*", "dist_*/**/*",
"assets/*", "dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js", "cli.js",
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"

View File

@ -22,6 +22,13 @@ tap.test('should produce a valid screenshot', async tools => {
expect(result.buffer).to.be.instanceOf(Buffer); expect(result.buffer).to.be.instanceOf(Buffer);
}); });
tap.test('should evalute something in the browser', async () => {
const result = await testSmartBrowser.evaluateOnPage('https://lossless.com', async () => {
return 'hi';
});
console.log(result);
});
tap.test('should stop the browser ', async () => { tap.test('should stop the browser ', async () => {
await expect(testSmartBrowser.stop()).to.eventually.be.fulfilled; await expect(testSmartBrowser.stop()).to.eventually.be.fulfilled;
}); });

View File

@ -61,12 +61,13 @@ export class SmartBrowser {
* @param urlArg * @param urlArg
* @param funcArg * @param funcArg
*/ */
public async evaluateOnPage(urlArg: string, funcArg: () => Promise<any>) { public async evaluateOnPage<T>(urlArg: string, funcArg: () => Promise<T>) {
const page = await this.headlessBrowser.newPage(); const page = await this.headlessBrowser.newPage();
await page.goto(urlArg, { await page.goto(urlArg, {
waitUntil: 'networkidle2' waitUntil: 'networkidle2'
}); });
const result = await page.evaluate(funcArg);
await page.close();
return result;
} }
} }