Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
c13a125ac7 | |||
8f6949b1b8 | |||
9b698c6dea | |||
157bcff7c4 | |||
934423f0ad | |||
e6d7fdced6 | |||
2fc4e691ac | |||
7e8035ea61 | |||
1bc3112bb7 | |||
4a177fd166 | |||
c1cf019af2 | |||
9ecf7c81d4 | |||
8fa40087d4 | |||
a5576410cd |
@ -12,6 +12,9 @@ stages:
|
|||||||
- release
|
- release
|
||||||
- metadata
|
- metadata
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- npm install -g @shipzone/npmci
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# security stage
|
# security stage
|
||||||
# ====================
|
# ====================
|
||||||
@ -19,23 +22,36 @@ mirror:
|
|||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
- npmci git mirror
|
- npmci git mirror
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
- lossless
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
audit:
|
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
|
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 --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command npm config set registry https://registry.npmjs.org
|
- npmci command npm config set registry https://registry.npmjs.org
|
||||||
- npmci command npm audit --audit-level=high
|
- npmci command npm audit --audit-level=high --only=dev
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
allow_failure: true
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
@ -50,9 +66,7 @@ testStable:
|
|||||||
- npmci npm test
|
- npmci npm test
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- priv
|
|
||||||
|
|
||||||
testBuild:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
@ -63,9 +77,7 @@ testBuild:
|
|||||||
- npmci command npm run build
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- lossless
|
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
@ -85,6 +97,8 @@ release:
|
|||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
|
only:
|
||||||
|
- tags
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g tslint typescript
|
- npmci command npm install -g tslint typescript
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
|
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"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
2
.vscode/settings.json
vendored
2
.vscode/settings.json
vendored
@ -15,7 +15,7 @@
|
|||||||
"properties": {
|
"properties": {
|
||||||
"projectType": {
|
"projectType": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": ["website", "element", "service", "npm"]
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"npmci": {
|
||||||
"globalNpmTools": [
|
"npmAccessLevel": "public"
|
||||||
"npmts"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
"projectType": "npm",
|
"projectType": "npm",
|
||||||
|
17476
package-lock.json
generated
17476
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
24
package.json
24
package.json
@ -1,12 +1,13 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartbrowser",
|
"name": "@pushrocks/smartbrowser",
|
||||||
"version": "1.0.16",
|
"version": "2.0.0",
|
||||||
"description": "simplified puppeteer",
|
"description": "simplified 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",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/ --web)",
|
"test": "(tstest test/ --web)",
|
||||||
"build": "(tsbuild --web)"
|
"build": "(tsbuild --web --allowimplicitany)"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@ -19,19 +20,19 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://gitlab.com/pushrocks/smartbrowser#README",
|
"homepage": "https://gitlab.com/pushrocks/smartbrowser#README",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartdelay": "^2.0.9",
|
"@pushrocks/smartdelay": "^2.0.13",
|
||||||
"@pushrocks/smartpdf": "^2.0.2",
|
"@pushrocks/smartpdf": "^3.0.0",
|
||||||
"@pushrocks/smartpuppeteer": "^1.0.15",
|
"@pushrocks/smartpuppeteer": "^2.0.0",
|
||||||
"@pushrocks/smartunique": "^3.0.3"
|
"@pushrocks/smartunique": "^3.0.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.24",
|
"@gitzone/tsbuild": "^2.1.60",
|
||||||
"@gitzone/tstest": "^1.0.32",
|
"@gitzone/tstest": "^1.0.69",
|
||||||
"@pushrocks/tapbundle": "^3.2.1",
|
"@pushrocks/tapbundle": "^5.0.3",
|
||||||
"tslint": "^6.1.2",
|
"tslint": "^6.1.3",
|
||||||
"tslint-config-prettier": "^1.18.0"
|
"tslint-config-prettier": "^1.18.0"
|
||||||
},
|
},
|
||||||
"private": true,
|
"private": false,
|
||||||
"files": [
|
"files": [
|
||||||
"ts/**/*",
|
"ts/**/*",
|
||||||
"ts_web/**/*",
|
"ts_web/**/*",
|
||||||
@ -43,5 +44,8 @@
|
|||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
"readme.md"
|
"readme.md"
|
||||||
|
],
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@ TypeScript 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)
|
||||||
|
|
||||||
@ -27,7 +27,6 @@ Platform support | [ or [contribute monthly](https://lossless.link/contribute). :)
|
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). :)
|
||||||
|
18
test/test.ts
18
test/test.ts
@ -1,25 +1,25 @@
|
|||||||
import { tap, expect } from '@pushrocks/tapbundle';
|
import { tap, expect, expectAsync } from '@pushrocks/tapbundle';
|
||||||
|
|
||||||
import * as smartbrowser from '../ts/index';
|
import * as smartbrowser from '../ts/index.js';
|
||||||
let testSmartBrowser: smartbrowser.SmartBrowser;
|
let testSmartBrowser: smartbrowser.SmartBrowser;
|
||||||
|
|
||||||
tap.test('should instanstiate a new browser ', async () => {
|
tap.test('should instanstiate a new browser ', async () => {
|
||||||
testSmartBrowser = new smartbrowser.SmartBrowser();
|
testSmartBrowser = new smartbrowser.SmartBrowser();
|
||||||
return expect(testSmartBrowser).to.be.instanceof(smartbrowser.SmartBrowser);
|
return expect(testSmartBrowser).toBeInstanceOf(smartbrowser.SmartBrowser);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should start the browser ', async () => {
|
tap.test('should start the browser ', async () => {
|
||||||
await expect(testSmartBrowser.start()).to.eventually.be.fulfilled;
|
await testSmartBrowser.start();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should create a PDF from a page', async tools => {
|
tap.test('should create a PDF from a page', async (tools) => {
|
||||||
const result = await testSmartBrowser.pdfFromPage('https://lossless.com');
|
const result = await testSmartBrowser.pdfFromPage('https://lossless.com');
|
||||||
expect(result.buffer).to.be.instanceOf(Buffer);
|
expect(result.buffer).toBeInstanceOf(Buffer);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should produce a valid screenshot', async tools => {
|
tap.test('should produce a valid screenshot', async (tools) => {
|
||||||
const result = await testSmartBrowser.screenshotFromPage('https://lossless.com');
|
const result = await testSmartBrowser.screenshotFromPage('https://lossless.com');
|
||||||
expect(result.buffer).to.be.instanceOf(Buffer);
|
expect(result.buffer).toBeInstanceOf(Buffer);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should evalute something in the browser', async () => {
|
tap.test('should evalute something in the browser', async () => {
|
||||||
@ -30,7 +30,7 @@ tap.test('should evalute something in the browser', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should stop the browser ', async () => {
|
tap.test('should stop the browser ', async () => {
|
||||||
await expect(testSmartBrowser.stop()).to.eventually.be.fulfilled;
|
await testSmartBrowser.stop();
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
14
ts/index.ts
14
ts/index.ts
@ -1,6 +1,6 @@
|
|||||||
import * as plugins from './smartbrowser.plugins';
|
import * as plugins from './smartbrowser.plugins.js';
|
||||||
|
|
||||||
import * as interfaces from './interfaces';
|
import * as interfaces from './interfaces/index.js';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* SmartBrowser
|
* SmartBrowser
|
||||||
@ -43,16 +43,16 @@ export class SmartBrowser {
|
|||||||
const pageId = plugins.smartunique.shortId();
|
const pageId = plugins.smartunique.shortId();
|
||||||
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 screenshotBuffer = await page.screenshot({
|
const screenshotBuffer = await page.screenshot({
|
||||||
encoding: 'binary'
|
encoding: 'binary',
|
||||||
});
|
}) as Buffer;
|
||||||
await page.close();
|
await page.close();
|
||||||
return {
|
return {
|
||||||
name: pageId,
|
name: pageId,
|
||||||
id: `${pageId}.js`,
|
id: `${pageId}.js`,
|
||||||
buffer: screenshotBuffer
|
buffer: screenshotBuffer,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ export class SmartBrowser {
|
|||||||
public async evaluateOnPage<T>(urlArg: string, funcArg: () => Promise<T>) {
|
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);
|
const result = await page.evaluate(funcArg);
|
||||||
await page.close();
|
await page.close();
|
||||||
|
@ -1 +1 @@
|
|||||||
export * from './interfaces.screenshotresult';
|
export * from './interfaces.screenshotresult.js';
|
||||||
|
Reference in New Issue
Block a user