Compare commits

..

12 Commits

Author SHA1 Message Date
aa0ad1dce5 3.0.14 2022-10-26 23:04:59 +02:00
65756457aa fix(core): update 2022-10-26 23:04:59 +02:00
67f21d2500 3.0.13 2022-10-26 22:58:26 +02:00
1cf095a5cc fix(core): update 2022-10-26 22:58:26 +02:00
ffeaec7fe9 3.0.12 2022-09-16 08:27:25 +02:00
a31e196e5b fix(core): update 2022-09-16 08:27:25 +02:00
57851d90a5 3.0.11 2022-09-15 20:52:22 +02:00
1e4b16b734 fix(core): update 2022-09-15 20:52:22 +02:00
876466b18d 3.0.10 2022-09-13 18:39:38 +02:00
82b1c187ee fix(core): update 2022-09-13 18:39:38 +02:00
4f93d258b8 3.0.9 2022-09-13 18:26:15 +02:00
60993fc005 fix(core): update 2022-09-13 18:26:14 +02:00
12 changed files with 4209 additions and 13282 deletions

View File

@ -12,40 +12,36 @@ stages:
- release
- metadata
before_script:
- pnpm install -g pnpm
- pnpm install -g @shipzone/npmci
- npmci npm prepare
# ====================
# security stage
# ====================
# ====================
# 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
- npmci command npm config set registry https://registry.npmjs.org
- npmci command pnpm audit --audit-level=high --prod
tags:
- lossless
- 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
- npmci command pnpm audit --audit-level=high --dev
tags:
- lossless
- docker
allow_failure: true
@ -56,7 +52,6 @@ auditDevDependencies:
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci npm test
@ -67,7 +62,6 @@ testStable:
testBuild:
stage: test
script:
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command npm run build
@ -96,10 +90,9 @@ codequality:
only:
- tags
script:
- npmci command npm install -g tslint typescript
- npmci command npm install -g typescript
- npmci npm prepare
- npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- lossless
- docker
@ -119,11 +112,9 @@ trigger:
pages:
stage: metadata
script:
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci node install stable
- npmci npm install
- npmci command tsdoc
- npmci command npm run buildDocs
tags:
- lossless
- docker

24
.vscode/launch.json vendored
View File

@ -2,28 +2,10 @@
"version": "0.2.0",
"configurations": [
{
"name": "current file",
"type": "node",
"command": "npm test",
"name": "Run npm test",
"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"
"type": "node-terminal"
}
]
}

View File

@ -9,7 +9,7 @@
"githost": "gitlab.com",
"gitscope": "pushrocks",
"gitrepo": "smartpdf",
"shortDescription": "Create PDFs fast and smoothly",
"description": "Create PDFs fast and smoothly",
"npmPackagename": "@pushrocks/smartpdf",
"license": "MIT"
}

13210
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,6 @@
{
"name": "@pushrocks/smartpdf",
"version": "3.0.8",
"version": "3.0.14",
"private": false,
"description": "create pdfs on the fly",
"main": "dist_ts/index.js",
@ -10,26 +10,29 @@
"license": "MIT",
"scripts": {
"test": "(tstest test/ --web)",
"build": "(tsbuild --web --allowimplicitany)"
"build": "(tsbuild --web --allowimplicitany)",
"buildDocs": "tsdoc"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.1.65",
"@gitzone/tsdoc": "^1.1.12",
"@gitzone/tsrun": "^1.2.35",
"@gitzone/tstest": "^1.0.73",
"@pushrocks/tapbundle": "^5.0.4",
"@types/node": "^18.7.14"
"@types/node": "^18.7.18"
},
"dependencies": {
"@pushrocks/smartdelay": "^2.0.13",
"@pushrocks/smartfile": "^10.0.5",
"@pushrocks/smartnetwork": "^3.0.0",
"@pushrocks/smartpath": "^5.0.5",
"@pushrocks/smartpromise": "^3.1.7",
"@pushrocks/smartpuppeteer": "^2.0.2",
"@pushrocks/smartunique": "^3.0.3",
"@tsclass/tsclass": "^4.0.19",
"@types/express": "^4.17.13",
"@tsclass/tsclass": "^4.0.21",
"@types/express": "^4.17.14",
"express": "^4.18.1",
"pdf-merger-js": "^4.1.0",
"pdf-merger-js": "^3.4.0",
"pdf2json": "^2.0.0"
},
"files": [

4148
pnpm-lock.yaml generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -39,17 +39,19 @@ tap.test('should create a valid PDFResult', async () => {
}
fs.writeFileSync(`.nogit/${fileName}`, pdfResult.buffer as Buffer);
};
await writePDfToDisk('https://maintainedby.lossless.com/', '1.pdf')
await writePDfToDisk('https://rendertron.lossless.one/render/https://layer.io', '2.pdf')
await writePDfToDisk('https://maintainedby.lossless.com/', '1.pdf');
await writePDfToDisk('https://rendertron.lossless.one/render/https://layer.io', '2.pdf');
});
tap.test('should combine pdfs', async () => {
const fs = await import('fs');
const pdf1 = await testSmartPdf.readFileToPdfObject('.nogit/1.pdf');
const pdf2 = await testSmartPdf.readFileToPdfObject('.nogit/2.pdf');
fs.writeFileSync(`.nogit/combined.pdf`, (await testSmartPdf.mergePdfs([pdf1, pdf2])).buffer as Buffer);
})
fs.writeFileSync(
`.nogit/combined.pdf`,
(await testSmartPdf.mergePdfs([pdf1, pdf2])).buffer as Buffer
);
});
tap.test('should be able to close properly', async () => {
await testSmartPdf.stop();

View File

@ -3,6 +3,6 @@
*/
export const commitinfo = {
name: '@pushrocks/smartpdf',
version: '3.0.8',
version: '3.0.14',
description: 'create pdfs on the fly'
}

View File

@ -1,7 +1,7 @@
/*
* pdf candidate is a construct used internally for mapping html
* to pdf buffers delivered by puppeteer
*/
* pdf candidate is a construct used internally for mapping html
* to pdf buffers delivered by puppeteer
*/
import * as plugins from './smartpdf.plugins.js';
export class PdfCandidate {

View File

@ -84,6 +84,7 @@ export class SmartPdf {
const response = await page.goto(`http://localhost:3210/${pdfCandidate.pdfId}`, {
waitUntil: 'networkidle2',
});
// await plugins.smartdelay.delayFor(1000);
const headers = response.headers();
if (headers['pdf-id'] !== pdfCandidate.pdfId) {
console.log('Error! Headers do not match. For security reasons no pdf is being emitted!');
@ -185,14 +186,14 @@ export class SmartPdf {
public async mergePdfs(pdfArrayArg: plugins.tsclass.business.IPdf[]): Promise<IPdf> {
const merger = new plugins.pdfMerger();
for (const pdf of pdfArrayArg) {
merger.add(pdf.buffer as Buffer);
merger.add(Buffer.from(pdf.buffer));
}
const resultBuffer = await merger.saveAsBuffer();
return {
name: 'mergedPdf',
buffer: resultBuffer,
id: null,
metadata: null
metadata: null,
};
}
@ -204,8 +205,8 @@ export class SmartPdf {
name: parsedPath.base,
buffer,
id: null,
metadata: null
}
metadata: null,
};
}
public async extractTextFromPdfBuffer(pdfBufferArg: Buffer): Promise<string> {

View File

@ -1,3 +1,6 @@
import * as plugins from './smartpdf.plugins.js';
export const packageDir = plugins.path.join(plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url), '../');
export const packageDir = plugins.path.join(
plugins.smartpath.get.dirnameFromImportMetaUrl(import.meta.url),
'../'
);

View File

@ -6,20 +6,27 @@ export { http, path };
// @pushrocks
import * as smartfile from '@pushrocks/smartfile';
import * as smartdelay from '@pushrocks/smartdelay';
import * as smartpromise from '@pushrocks/smartpromise';
import * as smartpath from '@pushrocks/smartpath';
import * as smartpuppeteer from '@pushrocks/smartpuppeteer';
import * as smartnetwork from '@pushrocks/smartnetwork';
import * as smartunique from '@pushrocks/smartunique';
export { smartfile, smartpromise, smartpath, smartpuppeteer, smartunique, smartnetwork };
export {
smartfile,
smartdelay,
smartpromise,
smartpath,
smartpuppeteer,
smartunique,
smartnetwork,
};
// tsclass scope
import * as tsclass from '@tsclass/tsclass';
export {
tsclass
}
export { tsclass };
// thirdparty
import pdfMerger from 'pdf-merger-js';