Compare commits

...

26 Commits

Author SHA1 Message Date
1f7be6b8a0 2.0.18 2020-07-08 19:01:56 +00:00
a0cbe170c8 2.0.17 2020-07-08 11:10:20 +00:00
5df46f8b77 fix(core): update 2020-07-08 11:10:20 +00:00
c12e9eaf76 2.0.16 2020-06-27 12:51:34 +00:00
2aa1839c22 fix(core): update 2020-06-27 12:51:34 +00:00
8e4bdb867c 2.0.15 2020-06-27 12:50:45 +00:00
359e18f5dc fix(core): update 2020-06-27 12:50:44 +00:00
751a325c81 2.0.14 2020-03-15 19:11:14 +00:00
93d4bc491f fix(core): update 2020-03-15 19:11:14 +00:00
bdf55a19d9 2.0.13 2020-03-13 11:46:21 +00:00
cd1f68f55e fix(core): update 2020-03-13 11:46:20 +00:00
f2bd7145b3 2.0.12 2020-03-08 15:14:25 +00:00
6d9789df45 fix(core): update 2020-03-08 15:14:24 +00:00
0be8a6f60d 2.0.11 2020-03-08 10:54:12 +00:00
a3793572e7 fix(core): update 2020-03-08 10:54:12 +00:00
6ace59d1d1 2.0.10 2020-03-08 10:48:23 +00:00
b6ddf6a87b 2.0.9 2020-03-07 22:01:04 +00:00
b999627ba5 fix(core): update 2020-03-07 22:01:03 +00:00
5e8a91f302 2.0.8 2020-03-07 16:23:12 +00:00
2fc0613fa6 fix(core): update 2020-03-07 16:23:12 +00:00
2283cdb633 2.0.7 2020-03-07 16:08:22 +00:00
c0db06fc18 fix(core): update 2020-03-07 16:08:21 +00:00
4557000629 2.0.6 2020-03-06 15:26:27 +00:00
78997e1e5a fix(core): update 2020-03-06 15:26:26 +00:00
4d5564e8d4 2.0.5 2020-03-06 15:12:24 +00:00
11d89adc4b fix(core): update 2020-03-06 15:12:23 +00:00
11 changed files with 10093 additions and 477 deletions

4
.gitignore vendored
View File

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

View File

@ -24,13 +24,14 @@ mirror:
- 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

10344
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,38 +1,44 @@
{
"name": "@pushrocks/websetup",
"version": "2.0.4",
"version": "2.0.18",
"private": false,
"description": "setup basic page properties",
"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": {
"test": "(tstest test/)",
"build": "(tsbuild --web)",
"format": "(gitzone format)"
"build": "(tsbuild --web && tsbundle npm)"
},
"keywords": [
"lossless",
"websafe"
],
"devDependencies": {
"@gitzone/tsbuild": "^2.1.17",
"@gitzone/tstest": "^1.0.28",
"@pushrocks/tapbundle": "^3.2.0",
"tslint": "^6.0.0",
"@gitzone/tsbuild": "^2.1.22",
"@gitzone/tsbundle": "^1.0.72",
"@gitzone/tstest": "^1.0.38",
"@pushrocks/tapbundle": "^3.2.7",
"tslint": "^6.1.0",
"tslint-config-prettier": "^1.15.0"
},
"dependencies": {},
"dependencies": {
"@tsclass/tsclass": "^3.0.18"
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_web/**/*",
"dist_*/**/*",
"dist_ts/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
],
"browserslist": [
"last 1 chrome versions"
]
}

View File

@ -8,16 +8,24 @@ setup basic page properties
* [docs (typedoc)](https://pushrocks.gitlab.io/websetup/)
## Status for master
[![pipeline status](https://gitlab.com/pushrocks/websetup/badges/master/pipeline.svg)](https://gitlab.com/pushrocks/websetup/commits/master)
[![coverage report](https://gitlab.com/pushrocks/websetup/badges/master/coverage.svg)](https://gitlab.com/pushrocks/websetup/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/websetup.svg)](https://www.npmjs.com/package/@pushrocks/websetup)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/websetup/badge.svg)](https://snyk.io/test/npm/@pushrocks/websetup)
[![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/websetup/badges/master/pipeline.svg)](https://lossless.cloud)
GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/websetup/badges/master/coverage.svg)](https://lossless.cloud)
npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/websetup)](https://lossless.cloud)
Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/websetup)](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/websetup)](https://lossless.cloud)
PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/websetup)](https://lossless.cloud)
BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/websetup)](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
Use TypeScript for best in class intellisense.
## Contribution

16
test/test.browser.ts Normal file
View File

@ -0,0 +1,16 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as websetup from '../ts/index';
tap.test('first test', async () => {
const websetupInstance = new websetup.WebSetup({
metaObject: {
description: 'A awesome description',
title: 'mytitle',
canonicalDomain: 'lossless.com'
}
});
await websetupInstance.setup();
expect(document.title).to.equal('mytitle');
});
tap.start();

View File

@ -1,8 +0,0 @@
import { expect, tap } from '@pushrocks/tapbundle';
import * as websetup from '../ts/index';
tap.test('first test', async () => {
console.log('Waiting for proper puppeteer support here');
});
tap.start();

View File

@ -1,29 +1,122 @@
import * as plugins from '../websetup.plugins';
export interface IMetaObject {
title: string;
description: string;
canonicalDomain?: string;
ldCompany?: plugins.tsclass.business.ICompany;
ldProduct?: any;
}
export const setupMetaInformation = async (metaObjectArg: IMetaObject) => {
document.title = metaObjectArg.title;
addMetaTag('description', metaObjectArg.description);
addMetaTag('google', 'notranslate');
addMetaTag('revisited-after', '1 days');
addMetaTag('revisit-after', '1 days');
metaObjectArg.canonicalDomain ? addLinkTag('canonical', metaObjectArg.canonicalDomain) : null;
if (metaObjectArg.ldCompany) {
addCompanyInfo(metaObjectArg.ldCompany);
}
};
const addMetaTag = async (linkNameArg: string, contentArg: string) => {
const addMetaTag = async (metaNameArg: string, contentArg: string) => {
const metaElement = document.createElement('meta');
metaElement.name = linkNameArg;
metaElement.name = metaNameArg;
metaElement.content = contentArg;
document.getElementsByTagName('head')[0].appendChild(metaElement);
};
const addLinkTag = async (relArg, hrefArg) => {
const addLinkTag = async (relArg, hrefArg): Promise<Element> => {
const link = !!document.querySelector("link[rel='canonical']")
? document.querySelector("link[rel='canonical']")
: document.createElement('link');
link.setAttribute('rel', relArg);
link.setAttribute('href', hrefArg);
document.head.appendChild(link);
return link;
};
const addOpenGraphProperty = async (
propertyNameArg: string,
contentArg: string
): Promise<Element> => {
const openGraphElement = document.createElement('meta');
openGraphElement.setAttribute('property', propertyNameArg);
openGraphElement.content = contentArg;
document.getElementsByTagName('head')[0].appendChild(openGraphElement);
return openGraphElement;
};
const addCompanyInfo = async (
companyDataArg: plugins.tsclass.business.ICompany
): Promise<Element[]> => {
const returnElementArray: Element[] = [];
// lets care about linked data
const companyLd = {
'@context': 'https://schema.org',
'@type': 'Corporation',
name: companyDataArg.name,
alternateName: companyDataArg.name.replace(' GmbH', ''),
url: companyDataArg.contact.website,
logo: companyDataArg.contact.logoUrl,
contactPoint: {
'@type': 'ContactPoint',
telephone: companyDataArg.contact.phone,
contactType: 'customer service',
areaServed: 'DE',
availableLanguage: ['en', 'German'],
},
sameAs: [],
};
if (companyDataArg.contact.facebookUrl) {
companyLd.sameAs.push(companyDataArg.contact.facebookUrl);
}
if (companyDataArg.contact.twitterUrl) {
companyLd.sameAs.push(companyDataArg.contact.twitterUrl);
}
const jsonLdElement = document.createElement('script');
jsonLdElement.type = 'application/ld+json';
jsonLdElement.text = JSON.stringify(companyLd);
document.querySelector('head').appendChild(jsonLdElement);
returnElementArray.push(jsonLdElement);
// lets care about open graph
returnElementArray.push(await addOpenGraphProperty('og:type', 'business.business'));
returnElementArray.push(await addOpenGraphProperty('og:title', companyDataArg.name));
returnElementArray.push(await addOpenGraphProperty('og:url', companyDataArg.contact.website));
returnElementArray.push(await addOpenGraphProperty('og:image', companyDataArg.contact.logoUrl));
returnElementArray.push(
await addOpenGraphProperty(
'business:contact_data:street_address',
`${companyDataArg.contact.address.streetName} ${companyDataArg.contact.address.houseNumber}`
)
);
returnElementArray.push(
await addOpenGraphProperty(
'business:contact_data:locality',
companyDataArg.contact.address.postalCode
)
);
returnElementArray.push(
await addOpenGraphProperty('business:contact_data:region', companyDataArg.contact.address.city)
);
returnElementArray.push(
await addOpenGraphProperty(
'business:contact_data:postal_code',
companyDataArg.contact.address.postalCode
)
);
returnElementArray.push(
await addOpenGraphProperty(
'business:contact_data:country_name',
companyDataArg.contact.address.country
)
);
return returnElementArray;
};

View File

@ -1,7 +1,10 @@
declare global {
// tslint:disable-next-line: interface-name
interface Window {
_fs_debug: boolean;
_fs_host: any;
_fs_org: string;
_fs_namespace: string;
}
}
export const setupFullStory = async (fsCodeArg: string) => {
@ -13,7 +16,7 @@ export const setupFullStory = async (fsCodeArg: string) => {
window['_fs_org'] = fsCodeArg;
// tslint:disable-next-line: no-string-literal
window['_fs_namespace'] = 'FS';
(function(m, n, e, t, l, o, g, y) {
((m, n, e, t, l, o, g, y) => {
if (e in m) {
if (m.console && m.console.log) {
m.console.log('FullStory namespace conflict. Please set window["_fs_namespace"].');
@ -21,7 +24,7 @@ export const setupFullStory = async (fsCodeArg: string) => {
return;
}
// tslint:disable-next-line: only-arrow-functions
g = m[e] = function(a, b, s) {
g = m[e] = function (a, b, s) {
g.q ? g.q.push([a, b, s]) : g._api(a, b, s);
};
g.q = [];
@ -32,36 +35,36 @@ export const setupFullStory = async (fsCodeArg: string) => {
y = n.getElementsByTagName(t)[0];
y.parentNode.insertBefore(o, y);
// tslint:disable-next-line: only-arrow-functions
g.identify = function(i, v, s) {
g.identify = function (i, v, s) {
g(l, { uid: i }, s);
if (v) g(l, v, s);
};
g.setUserVars = function(v, s) {
g.setUserVars = function (v, s) {
g(l, v, s);
};
g.event = function(i, v, s) {
g.event = function (i, v, s) {
g('event', { n: i, p: v }, s);
};
// tslint:disable-next-line: only-arrow-functions
g.shutdown = function() {
g.shutdown = function () {
g('rec', !1);
};
g.restart = function() {
g.restart = function () {
g('rec', !0);
};
// tslint:disable-next-line: only-arrow-functions
g.consent = function(a) {
g.consent = function (a) {
g('consent', !arguments.length || a);
};
// tslint:disable-next-line: only-arrow-functions
g.identifyAccount = function(i, v) {
g.identifyAccount = function (i, v) {
o = 'account';
v = v || {};
v.acctId = i;
g(o, v);
};
// tslint:disable-next-line: only-arrow-functions
g.clearUserCookie = function() {};
g.clearUserCookie = function () {};
// tslint:disable-next-line: no-string-literal
})(window, document, window['_fs_namespace'], 'script', 'user');
};

View File

@ -7,14 +7,14 @@ declare global {
export const setupGoogleAnalytics = async (gaCode: string) => {
// tslint:disable-next-line: only-arrow-functions
(function(i, s, o, g, r, a, m) {
(function (i, s, o, g, r, a, m) {
// tslint:disable-next-line: no-string-literal
i['GoogleAnalyticsObject'] = r;
// tslint:disable-next-line: ban-comma-operator
(i[r] =
i[r] ||
// tslint:disable-next-line: only-arrow-functions
function() {
function () {
(i[r].q = i[r].q || []).push(arguments);
}),
(i[r].l = new Date().getTime());

View File

@ -1,2 +1,3 @@
const removeme = {};
export { removeme };
import * as tsclass from '@tsclass/tsclass';
export { tsclass };