Compare commits
10 Commits
Author | SHA1 | Date | |
---|---|---|---|
d960d85539 | |||
ca60217a18 | |||
16f2829785 | |||
0381022b68 | |||
aae8ec0ee1 | |||
ec4768e1cc | |||
3308895b3b | |||
37e47fc33f | |||
b4a3a36b07 | |||
baf26dc492 |
3
.gitignore
vendored
3
.gitignore
vendored
@ -19,5 +19,4 @@ dist_web/
|
|||||||
dist_serve/
|
dist_serve/
|
||||||
dist_ts_web/
|
dist_ts_web/
|
||||||
|
|
||||||
# custom
|
# custom
|
||||||
assets/pdfdir
|
|
@ -1,5 +1,5 @@
|
|||||||
# gitzone standard
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
@ -49,14 +49,14 @@ testLTS:
|
|||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
testSTABLE:
|
testBuild:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
- npmci npm prepare
|
- npmci npm prepare
|
||||||
- npmci node install stable
|
- npmci node install lts
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci command npm run build
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
coverage: /\d+.?\d+?\%\s*coverage/
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
@ -65,7 +65,7 @@ testSTABLE:
|
|||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci node install stable
|
- npmci node install lts
|
||||||
- npmci npm publish
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
@ -78,19 +78,11 @@ 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 install
|
||||||
--env SOURCE_CODE="$PWD"
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
--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]
|
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- priv
|
- priv
|
||||||
@ -106,7 +98,9 @@ trigger:
|
|||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
pages:
|
pages:
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: hosttoday/ht-docker-dbase:npmci
|
||||||
|
services:
|
||||||
|
- docker:18-dind
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g @gitzone/tsdoc
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
|
9
.snyk
Normal file
9
.snyk
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
# Snyk (https://snyk.io) policy file, patches or ignores known vulnerabilities.
|
||||||
|
version: v1.13.5
|
||||||
|
# ignores vulnerabilities until expiry date; change duration by modifying expiry date
|
||||||
|
ignore:
|
||||||
|
SNYK-JS-LODASH-450202:
|
||||||
|
- '@pushrocks/smartnetwork > portscanner > async > lodash':
|
||||||
|
reason: None given
|
||||||
|
expires: '2019-09-13T09:39:26.276Z'
|
||||||
|
patch: {}
|
@ -5,7 +5,7 @@
|
|||||||
},
|
},
|
||||||
"gitzone": {
|
"gitzone": {
|
||||||
"module": {
|
"module": {
|
||||||
"githost": "gitlab.om",
|
"githost": "gitlab.com",
|
||||||
"gitscope": "pushrocks",
|
"gitscope": "pushrocks",
|
||||||
"gitrepo": "smartpdf",
|
"gitrepo": "smartpdf",
|
||||||
"shortDescription": "Create PDFs fast and smoothly",
|
"shortDescription": "Create PDFs fast and smoothly",
|
||||||
|
1576
package-lock.json
generated
1576
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
26
package.json
26
package.json
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartpdf",
|
"name": "@pushrocks/smartpdf",
|
||||||
"version": "1.0.17",
|
"version": "1.0.22",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "create pdfs on the fly",
|
"description": "create pdfs on the fly",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@ -13,27 +13,27 @@
|
|||||||
"build": "(tsbuild)"
|
"build": "(tsbuild)"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.11",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"@gitzone/tsrun": "^1.2.6",
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
"@gitzone/tstest": "^1.0.24",
|
"@gitzone/tstest": "^1.0.28",
|
||||||
"@pushrocks/tapbundle": "^3.0.9",
|
"@pushrocks/tapbundle": "^3.0.13",
|
||||||
"@types/node": "^12.0.3"
|
"@types/node": "^12.12.7"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@pushrocks/smartfile": "^7.0.2",
|
"@pushrocks/smartfile": "^7.0.6",
|
||||||
"@pushrocks/smartnetwork": "^1.1.6",
|
"@pushrocks/smartnetwork": "^1.1.14",
|
||||||
"@pushrocks/smartpromise": "^3.0.2",
|
"@pushrocks/smartpromise": "^3.0.6",
|
||||||
|
"@pushrocks/smartpuppeteer": "^1.0.5",
|
||||||
"@pushrocks/smartunique": "^3.0.1",
|
"@pushrocks/smartunique": "^3.0.1",
|
||||||
"@types/express": "^4.16.1",
|
"@types/express": "^4.17.2",
|
||||||
"@types/puppeteer": "^1.12.4",
|
"express": "^4.17.1"
|
||||||
"express": "^4.17.1",
|
|
||||||
"puppeteer": "^1.17.0"
|
|
||||||
},
|
},
|
||||||
"files": [
|
"files": [
|
||||||
"ts/*",
|
"ts/*",
|
||||||
"ts_web/*",
|
"ts_web/*",
|
||||||
"dist/*",
|
"dist/*",
|
||||||
"dist_web/*",
|
"dist_web/*",
|
||||||
|
"dist_ts_web/*",
|
||||||
"assets/*",
|
"assets/*",
|
||||||
"cli.js",
|
"cli.js",
|
||||||
"npmextra.json",
|
"npmextra.json",
|
||||||
|
10
readme.md
10
readme.md
@ -3,13 +3,13 @@ Create PDFs fast and smoothly
|
|||||||
|
|
||||||
## Availabililty and Links
|
## Availabililty and Links
|
||||||
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartpdf)
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartpdf)
|
||||||
* [gitlab.com (source)](https://gitlab.om/pushrocks/smartpdf)
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/smartpdf)
|
||||||
* [github.com (source mirror)](https://github.com/pushrocks/smartpdf)
|
* [github.com (source mirror)](https://github.com/pushrocks/smartpdf)
|
||||||
* [docs (typedoc)](https://pushrocks.gitlab.io/smartpdf/)
|
* [docs (typedoc)](https://pushrocks.gitlab.io/smartpdf/)
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
[](https://gitlab.om/pushrocks/smartpdf/commits/master)
|
[](https://gitlab.com/pushrocks/smartpdf/commits/master)
|
||||||
[](https://gitlab.om/pushrocks/smartpdf/commits/master)
|
[](https://gitlab.com/pushrocks/smartpdf/commits/master)
|
||||||
[](https://www.npmjs.com/package/@pushrocks/smartpdf)
|
[](https://www.npmjs.com/package/@pushrocks/smartpdf)
|
||||||
[](https://snyk.io/test/npm/@pushrocks/smartpdf)
|
[](https://snyk.io/test/npm/@pushrocks/smartpdf)
|
||||||
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
@ -21,6 +21,6 @@ Create PDFs fast and smoothly
|
|||||||
For further information read the linked docs at the top of this readme.
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
> 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)
|
||||||
|
|
||||||
[](https://maintainedby.lossless.com)
|
[](https://maintainedby.lossless.com)
|
||||||
|
10
test/test.ts
10
test/test.ts
@ -25,8 +25,16 @@ tap.test('should create a pdf from website as single page PDF', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should create a valid PDFResult', async () => {
|
tap.test('should create a valid PDFResult', async () => {
|
||||||
const pdfResult = await testSmartPdf.getFullWebsiteAsSinglePdf('https://maintainedby.lossless.com');
|
const pdfResult = await testSmartPdf.getFullWebsiteAsSinglePdf(
|
||||||
|
'https://maintainedby.lossless.com'
|
||||||
|
);
|
||||||
expect(pdfResult.buffer).to.be.instanceOf(Buffer);
|
expect(pdfResult.buffer).to.be.instanceOf(Buffer);
|
||||||
|
const fs = await import('fs');
|
||||||
|
|
||||||
|
if (!fs.existsSync('.nogit/')) {
|
||||||
|
fs.mkdirSync('.nogit/');
|
||||||
|
}
|
||||||
|
fs.writeFileSync('.nogit/sample.pdf', pdfResult.buffer);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should be able to close properly', async () => {
|
tap.test('should be able to close properly', async () => {
|
||||||
|
@ -1 +1 @@
|
|||||||
export * from './interface.pdfresult';
|
export * from './interface.pdfresult';
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
export interface IPdfResult {
|
export interface IPdfResult {
|
||||||
name: string,
|
name: string;
|
||||||
id: string,
|
id: string;
|
||||||
buffer: Buffer;
|
buffer: Buffer;
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,7 @@ import * as interfaces from './interfaces';
|
|||||||
export class SmartPdf {
|
export class SmartPdf {
|
||||||
htmlServerInstance: Server;
|
htmlServerInstance: Server;
|
||||||
serverPort: number;
|
serverPort: number;
|
||||||
headlessBrowser: plugins.puppeteer.Browser;
|
headlessBrowser: plugins.smartpuppeteer.puppeteer.Browser;
|
||||||
externalBrowserBool: boolean = false;
|
externalBrowserBool: boolean = false;
|
||||||
private _readyDeferred: plugins.smartpromise.Deferred<void>;
|
private _readyDeferred: plugins.smartpromise.Deferred<void>;
|
||||||
private _candidates: { [key: string]: PdfCandidate } = {};
|
private _candidates: { [key: string]: PdfCandidate } = {};
|
||||||
@ -21,18 +21,12 @@ export class SmartPdf {
|
|||||||
|
|
||||||
async start(headlessBrowserArg?) {
|
async start(headlessBrowserArg?) {
|
||||||
// lets set the external browser in case one is provided
|
// lets set the external browser in case one is provided
|
||||||
this.headlessBrowser = headlessBrowserArg
|
this.headlessBrowser = headlessBrowserArg;
|
||||||
// setup puppeteer
|
// setup puppeteer
|
||||||
if (this.headlessBrowser) {
|
if (this.headlessBrowser) {
|
||||||
this.externalBrowserBool = true;
|
this.externalBrowserBool = true;
|
||||||
} else {
|
} else {
|
||||||
let chromeArgs: string[] = [];
|
this.headlessBrowser = await plugins.smartpuppeteer.getEnvAwareBrowserInstance();
|
||||||
if(process.env.CI) {
|
|
||||||
chromeArgs = chromeArgs.concat(['--no-sandbox', '--disable-setuid-sandbox'])
|
|
||||||
}
|
|
||||||
this.headlessBrowser = await plugins.puppeteer.launch({
|
|
||||||
args: chromeArgs
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// setup server
|
// setup server
|
||||||
@ -56,7 +50,7 @@ export class SmartPdf {
|
|||||||
this.htmlServerInstance.close(() => {
|
this.htmlServerInstance.close(() => {
|
||||||
done.resolve();
|
done.resolve();
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!this.externalBrowserBool) {
|
if (!this.externalBrowserBool) {
|
||||||
await this.headlessBrowser.close();
|
await this.headlessBrowser.close();
|
||||||
}
|
}
|
||||||
|
@ -7,13 +7,13 @@ export { http, path };
|
|||||||
// @pushrocks
|
// @pushrocks
|
||||||
import * as smartfile from '@pushrocks/smartfile';
|
import * as smartfile from '@pushrocks/smartfile';
|
||||||
import * as smartpromise from '@pushrocks/smartpromise';
|
import * as smartpromise from '@pushrocks/smartpromise';
|
||||||
|
import * as smartpuppeteer from '@pushrocks/smartpuppeteer';
|
||||||
import * as smartnetwork from '@pushrocks/smartnetwork';
|
import * as smartnetwork from '@pushrocks/smartnetwork';
|
||||||
import * as smartunique from '@pushrocks/smartunique';
|
import * as smartunique from '@pushrocks/smartunique';
|
||||||
|
|
||||||
export { smartfile, smartpromise, smartunique, smartnetwork };
|
export { smartfile, smartpromise, smartpuppeteer, smartunique, smartnetwork };
|
||||||
|
|
||||||
// thirdparty
|
// thirdparty
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import puppeteer from 'puppeteer';
|
|
||||||
|
|
||||||
export { express, puppeteer };
|
export { express };
|
||||||
|
Reference in New Issue
Block a user