diff --git a/.gitignore b/.gitignore index 91c0db0..ef13c79 100644 --- a/.gitignore +++ b/.gitignore @@ -15,8 +15,6 @@ node_modules/ # builds dist/ -dist_web/ -dist_serve/ -dist_ts_web/ +dist_*/ # custom \ No newline at end of file diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index a95dfb6..d931318 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -19,22 +19,23 @@ mirror: stage: security script: - npmci git mirror + only: + - tags tags: - lossless - docker - notpriv -snyk: - image: registry.gitlab.com/hosttoday/ht-docker-node:snyk +audit: + image: registry.gitlab.com/hosttoday/ht-docker-node:npmci stage: security script: - npmci npm prepare - 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: - - lossless - docker - - notpriv # ==================== # test stage @@ -49,9 +50,7 @@ testStable: - npmci npm test coverage: /\d+.?\d+?\%\s*coverage/ tags: - - lossless - docker - - priv testBuild: stage: test @@ -62,9 +61,7 @@ testBuild: - npmci command npm run build coverage: /\d+.?\d+?\%\s*coverage/ tags: - - lossless - docker - - notpriv release: stage: release @@ -84,6 +81,8 @@ release: codequality: stage: metadata allow_failure: true + only: + - tags script: - npmci command npm install -g tslint typescript - npmci npm prepare diff --git a/.vscode/settings.json b/.vscode/settings.json index 01d2b8d..3648eaa 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -15,7 +15,7 @@ "properties": { "projectType": { "type": "string", - "enum": ["website", "element", "service", "npm"] + "enum": ["website", "element", "service", "npm", "wcc"] } } } diff --git a/package.json b/package.json index de18a51..75f5e44 100644 --- a/package.json +++ b/package.json @@ -3,8 +3,8 @@ "version": "1.0.10", "private": false, "description": "a smart server side renderer supporting shadow dom", - "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": { @@ -32,11 +32,15 @@ "ts/**/*", "ts_web/**/*", "dist/**/*", - "dist_web/**/*", + "dist_*/**/*", + "dist_ts/**/*", "dist_ts_web/**/*", "assets/**/*", "cli.js", "npmextra.json", "readme.md" + ], + "browserslist": [ + "last 1 chrome versions" ] -} +} \ No newline at end of file diff --git a/readme.md b/readme.md index 4370054..8f10119 100644 --- a/readme.md +++ b/readme.md @@ -8,13 +8,20 @@ a smart server side renderer supporting shadow dom * [docs (typedoc)](https://pushrocks.gitlab.io/smartssr/) ## Status for master -[![pipeline status](https://gitlab.com/pushrocks/smartssr/badges/master/pipeline.svg)](https://gitlab.com/pushrocks/smartssr/commits/master) -[![coverage report](https://gitlab.com/pushrocks/smartssr/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartssr/commits/master) -[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartssr.svg)](https://www.npmjs.com/package/@pushrocks/smartssr) -[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartssr/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartssr) -[![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/smartssr/badges/master/pipeline.svg)](https://lossless.cloud) +GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartssr/badges/master/coverage.svg)](https://lossless.cloud) +npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartssr)](https://lossless.cloud) +Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartssr)](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/smartssr)](https://lossless.cloud) +PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartssr)](https://lossless.cloud) +BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartssr)](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 diff --git a/test/test.ts b/test/test.ts index d641d8f..ea5f73c 100644 --- a/test/test.ts +++ b/test/test.ts @@ -5,7 +5,7 @@ let testSSRInstance: smartssr.SmartSSR; tap.test('should create a valid smartssr instance', async () => { testSSRInstance = new smartssr.SmartSSR({ - debug: true + debug: true, }); }); @@ -13,8 +13,10 @@ tap.test('should start the smartssr instance', async () => { await testSSRInstance.start(); }); -tap.test('should render central.eu', async tools => { - await testSSRInstance.renderPage('https://central.eu/article/5e76873b9cf69b7bf6bc78bc/Introducing%3A%20central.eu'); +tap.test('should render central.eu', async (tools) => { + await testSSRInstance.renderPage( + 'https://central.eu/article/5e76873b9cf69b7bf6bc78bc/Introducing%3A%20central.eu' + ); }); tap.skip.test('should render lossless.com', async () => { diff --git a/ts/smartssr.classes.smartssr.ts b/ts/smartssr.classes.smartssr.ts index 37d8564..1976c0a 100644 --- a/ts/smartssr.classes.smartssr.ts +++ b/ts/smartssr.classes.smartssr.ts @@ -16,10 +16,10 @@ export class SmartSSR { constructor(optionsArg?: ISmartSSROptions) { this.options = { - ... { - debug: false + ...{ + debug: false, }, - ...optionsArg + ...optionsArg, }; } @@ -42,17 +42,17 @@ export class SmartSSR { const resultDeferred = plugins.smartpromise.defer(); const context = await this.browser.createIncognitoBrowserContext(); const page = await context.newPage(); - page.on('console', msg => { + page.on('console', (msg) => { console.log(`${urlArg}: ${msg.text()}`); }); page.on('load', async (...args) => { await plugins.smartdelay.delayFor(5000); let screenshotBuffer: Buffer; - + if (this.options.debug) { screenshotBuffer = await page.screenshot({ - encoding: 'binary' + encoding: 'binary', }); } @@ -60,7 +60,7 @@ export class SmartSSR { const pageContent = await page.content(); const renderedPageString = pageContent; resultDeferred.resolve(renderedPageString); - + if (this.options.debug) { plugins.smartfile.memory.toFsSync( renderedPageString, @@ -69,7 +69,6 @@ export class SmartSSR { const fs = await import('fs'); fs.writeFileSync(plugins.path.join(paths.noGitDir, 'test.png'), screenshotBuffer); } - }); const renderTimeMeasurement = new plugins.smarttime.HrtMeasurement(); @@ -82,8 +81,12 @@ export class SmartSSR { context.close(); overallTimeMeasurement.stop(); - console.log(`Overall it took ${overallTimeMeasurement.milliSeconds} milliseconds to render ${urlArg}`); - console.log(`The rendering alone took ${renderTimeMeasurement.milliSeconds} milliseconds for ${urlArg}`) + console.log( + `Overall it took ${overallTimeMeasurement.milliSeconds} milliseconds to render ${urlArg}` + ); + console.log( + `The rendering alone took ${renderTimeMeasurement.milliSeconds} milliseconds for ${urlArg}` + ); return result; } } diff --git a/ts/smartssr.function.serialize.ts b/ts/smartssr.function.serialize.ts index 6f3fc3b..0f8cc6b 100644 --- a/ts/smartssr.function.serialize.ts +++ b/ts/smartssr.function.serialize.ts @@ -34,7 +34,7 @@ export function serializeFunction(rootNode) { // console.log(nodeArg.nodeName); if (nodeArg.shadowRoot) { nodeArg.setAttribute('smartssr', 'yes'); - + // lets handle the current node const nodeUUID = uuidv4(); @@ -64,7 +64,7 @@ export function serializeFunction(rootNode) { noteForAppending.push(childNode); } }); - noteForAppending.forEach(childNode => { + noteForAppending.forEach((childNode) => { nodeArg.append(childNode); }); } else {