Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
74d73a0d21 | |||
5496c8c482 | |||
c748c5102c | |||
308133fe4f | |||
cb80b4df75 | |||
74ed988da0 | |||
d1793f9084 | |||
4a45262124 | |||
f5f51ac1a6 | |||
eb4a4288ed | |||
56bcfcdae4 | |||
50b33a5f88 | |||
d24593b07c | |||
9eb9f14a38 |
@ -34,28 +34,6 @@ snyk:
|
|||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
sast:
|
|
||||||
stage: security
|
|
||||||
image: docker:stable
|
|
||||||
variables:
|
|
||||||
DOCKER_DRIVER: overlay2
|
|
||||||
allow_failure: true
|
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
script:
|
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
|
||||||
- docker run
|
|
||||||
--env SAST_CONFIDENCE_LEVEL="${SAST_CONFIDENCE_LEVEL:-3}"
|
|
||||||
--volume "$PWD:/code"
|
|
||||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
"registry.gitlab.com/gitlab-org/security-products/sast:$SP_VERSION" /app/bin/run /code
|
|
||||||
artifacts:
|
|
||||||
reports:
|
|
||||||
sast: gl-sast-report.json
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# test stage
|
||||||
# ====================
|
# ====================
|
||||||
|
@ -2,5 +2,15 @@
|
|||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmAccessLevel": "public"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"module": {
|
||||||
|
"githost": "gitlab.com",
|
||||||
|
"gitscope": "pushrocks",
|
||||||
|
"gitrepo": "websetup",
|
||||||
|
"shortDescription": "setup basic page properties",
|
||||||
|
"npmPackagename": "@pushrocks/websetup",
|
||||||
|
"license": "MIT"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
1617
package-lock.json
generated
Normal file
1617
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/websetup",
|
"name": "@pushrocks/websetup",
|
||||||
"version": "1.0.2",
|
"version": "2.0.0",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "setup basic page properties",
|
"description": "setup basic page properties",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
@ -9,14 +9,17 @@
|
|||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "(tstest test/)",
|
||||||
"build": "(tsbuild)",
|
"build": "(tsbuild --web)",
|
||||||
"format": "(gitzone format)"
|
"format": "(gitzone format)"
|
||||||
},
|
},
|
||||||
|
"keywords": [
|
||||||
|
"lossless",
|
||||||
|
"websafe"
|
||||||
|
],
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.0.22",
|
"@gitzone/tsbuild": "^2.0.22",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tstest": "^1.0.15",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^3.0.7",
|
||||||
"@types/node": "^10.11.7",
|
|
||||||
"tslint": "^5.11.0",
|
"tslint": "^5.11.0",
|
||||||
"tslint-config-prettier": "^1.15.0"
|
"tslint-config-prettier": "^1.15.0"
|
||||||
},
|
},
|
||||||
|
26
readme.md
Normal file
26
readme.md
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
# @pushrocks/websetup
|
||||||
|
setup basic page properties
|
||||||
|
|
||||||
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/websetup)
|
||||||
|
* [gitlab.com (source)](https://gitlab.com/pushrocks/websetup)
|
||||||
|
* [github.com (source mirror)](https://github.com/pushrocks/websetup)
|
||||||
|
* [docs (typedoc)](https://pushrocks.gitlab.io/websetup/)
|
||||||
|
|
||||||
|
## Status for master
|
||||||
|
[](https://gitlab.com/pushrocks/websetup/commits/master)
|
||||||
|
[](https://gitlab.com/pushrocks/websetup/commits/master)
|
||||||
|
[](https://www.npmjs.com/package/@pushrocks/websetup)
|
||||||
|
[](https://snyk.io/test/npm/@pushrocks/websetup)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
|
[](https://prettier.io/)
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
For further information read the linked docs at the top of this readme.
|
||||||
|
|
||||||
|
> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh)
|
||||||
|
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
|
||||||
|
|
||||||
|
[](https://maintainedby.lossless.com)
|
@ -1,8 +1,8 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
import { expect, tap } from '@pushrocks/tapbundle';
|
||||||
import * as websetup from '../ts/index'
|
import * as websetup from '../ts/index';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
tap.test('first test', async () => {
|
||||||
console.log(websetup.standardExport)
|
console.log('Waiting for proper puppeteer support here');
|
||||||
})
|
});
|
||||||
|
|
||||||
tap.start()
|
tap.start();
|
||||||
|
32
ts/index.ts
32
ts/index.ts
@ -1,3 +1,33 @@
|
|||||||
import * as plugins from './websetup.plugins';
|
import * as plugins from './websetup.plugins';
|
||||||
|
|
||||||
export let standardExport = 'Hi there! :) This is an exported string';
|
import { setupGoogleAnalytics } from './tools/ganalytics';
|
||||||
|
import { setupFullStory } from './tools/fullstory';
|
||||||
|
import { IMetaObject, setupMetaInformation } from './meta';
|
||||||
|
|
||||||
|
export interface IWebSetupConstructorOptions {
|
||||||
|
googleAnalyticsCode?: string;
|
||||||
|
fsCode?: string;
|
||||||
|
metaObject: IMetaObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* the main WebSetup class
|
||||||
|
*/
|
||||||
|
export class WebSetup {
|
||||||
|
public options: IWebSetupConstructorOptions;
|
||||||
|
constructor(optionsArg: IWebSetupConstructorOptions) {
|
||||||
|
this.options = optionsArg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async setup() {
|
||||||
|
await setupMetaInformation(this.options.metaObject);
|
||||||
|
|
||||||
|
if (this.options.googleAnalyticsCode) {
|
||||||
|
await setupGoogleAnalytics(this.options.googleAnalyticsCode);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.options.fsCode) {
|
||||||
|
await setupFullStory(this.options.fsCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
18
ts/meta/index.ts
Normal file
18
ts/meta/index.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
export interface IMetaObject {
|
||||||
|
title: string;
|
||||||
|
description: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const setupMetaInformation = async (metaObjectArg: IMetaObject) => {
|
||||||
|
document.title = metaObjectArg.title;
|
||||||
|
addMetaTag('description', metaObjectArg.description);
|
||||||
|
addMetaTag('google', 'notranslate');
|
||||||
|
addMetaTag('revisited-after', '1 days');
|
||||||
|
};
|
||||||
|
|
||||||
|
const addMetaTag = async (linkNameArg: string, contentArg: string) => {
|
||||||
|
const metaElement = document.createElement('meta');
|
||||||
|
metaElement.name = linkNameArg;
|
||||||
|
metaElement.content = contentArg;
|
||||||
|
document.getElementsByTagName('head')[0].appendChild(metaElement);
|
||||||
|
};
|
66
ts/tools/fullstory.ts
Normal file
66
ts/tools/fullstory.ts
Normal file
@ -0,0 +1,66 @@
|
|||||||
|
declare global {
|
||||||
|
// tslint:disable-next-line: interface-name
|
||||||
|
interface Window {
|
||||||
|
_fs_host: any;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
export const setupFullStory = async (fsCodeArg: string) => {
|
||||||
|
// tslint:disable-next-line: no-string-literal
|
||||||
|
window['_fs_debug'] = false;
|
||||||
|
// tslint:disable-next-line: no-string-literal
|
||||||
|
window['_fs_host'] = 'fullstory.com';
|
||||||
|
// tslint:disable-next-line: no-string-literal
|
||||||
|
window['_fs_org'] = fsCodeArg;
|
||||||
|
// tslint:disable-next-line: no-string-literal
|
||||||
|
window['_fs_namespace'] = 'FS';
|
||||||
|
(function(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"].');
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// tslint:disable-next-line: only-arrow-functions
|
||||||
|
g = m[e] = function(a, b, s) {
|
||||||
|
g.q ? g.q.push([a, b, s]) : g._api(a, b, s);
|
||||||
|
};
|
||||||
|
g.q = [];
|
||||||
|
o = n.createElement(t);
|
||||||
|
o.async = 1;
|
||||||
|
o.src = 'https://' + window._fs_host + '/s/fs.js';
|
||||||
|
y = n.getElementsByTagName(t)[0];
|
||||||
|
y.parentNode.insertBefore(o, y);
|
||||||
|
// tslint:disable-next-line: only-arrow-functions
|
||||||
|
g.identify = function(i, v, s) {
|
||||||
|
g(l, { uid: i }, s);
|
||||||
|
if (v) g(l, v, s);
|
||||||
|
};
|
||||||
|
g.setUserVars = function(v, s) {
|
||||||
|
g(l, 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('rec', !1);
|
||||||
|
};
|
||||||
|
g.restart = function() {
|
||||||
|
g('rec', !0);
|
||||||
|
};
|
||||||
|
// tslint:disable-next-line: only-arrow-functions
|
||||||
|
g.consent = function(a) {
|
||||||
|
g('consent', !arguments.length || a);
|
||||||
|
};
|
||||||
|
// tslint:disable-next-line: only-arrow-functions
|
||||||
|
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() {};
|
||||||
|
// tslint:disable-next-line: no-string-literal
|
||||||
|
})(window, document, window['_fs_namespace'], 'script', 'user');
|
||||||
|
};
|
31
ts/tools/ganalytics.ts
Normal file
31
ts/tools/ganalytics.ts
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
declare global {
|
||||||
|
// tslint:disable-next-line: interface-name
|
||||||
|
interface Window {
|
||||||
|
analytics: any;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const setupGoogleAnalytics = async (gaCode: string) => {
|
||||||
|
// tslint:disable-next-line: only-arrow-functions
|
||||||
|
(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() {
|
||||||
|
(i[r].q = i[r].q || []).push(arguments);
|
||||||
|
}),
|
||||||
|
(i[r].l = new Date().getTime());
|
||||||
|
// tslint:disable-next-line: ban-comma-operator
|
||||||
|
(a = s.createElement(o)), (m = s.getElementsByTagName(o)[0]);
|
||||||
|
a.async = 1;
|
||||||
|
a.src = g;
|
||||||
|
m.parentNode.insertBefore(a, m);
|
||||||
|
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'analytics');
|
||||||
|
|
||||||
|
window.analytics('create', gaCode, 'auto');
|
||||||
|
window.analytics('send', 'pageview');
|
||||||
|
console.log('Loaded Google Analytics. You may view our privacy policy at https://lossless.gmbh');
|
||||||
|
};
|
@ -1,4 +1,2 @@
|
|||||||
const removeme = {};
|
const removeme = {};
|
||||||
export {
|
export { removeme };
|
||||||
removeme
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user