fix(core): update

This commit is contained in:
Philipp Kunz 2023-05-07 20:24:53 +02:00
parent d1c0501461
commit d381f8adad
22 changed files with 4620 additions and 27105 deletions

View File

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

24
.vscode/launch.json vendored
View File

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

View File

@ -9,7 +9,7 @@
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "pushrocks", "gitscope": "pushrocks",
"gitrepo": "websetup", "gitrepo": "websetup",
"shortDescription": "setup basic page properties", "description": "setup basic page properties",
"npmPackagename": "@pushrocks/websetup", "npmPackagename": "@pushrocks/websetup",
"license": "MIT" "license": "MIT"
} }

26980
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,24 +9,23 @@
"license": "MIT", "license": "MIT",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"build": "(tsbuild --web && tsbundle npm)" "build": "(tsbuild --web --allowimplicitany && tsbundle npm)",
"buildDocs": "tsdoc"
}, },
"keywords": [ "keywords": [
"lossless", "lossless",
"websafe" "websafe"
], ],
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.28", "@gitzone/tsbuild": "^2.1.65",
"@gitzone/tsbundle": "^1.0.88", "@gitzone/tsbundle": "^2.0.7",
"@gitzone/tstest": "^1.0.60", "@gitzone/tstest": "^1.0.74",
"@pushrocks/tapbundle": "^3.2.15", "@pushrocks/tapbundle": "^5.0.4"
"tslint": "^6.1.3",
"tslint-config-prettier": "^1.15.0"
}, },
"dependencies": { "dependencies": {
"@pushrocks/smartdelay": "^2.0.13", "@pushrocks/smartdelay": "^3.0.1",
"@pushrocks/smartpromise": "^3.1.6", "@pushrocks/smartpromise": "^4.0.2",
"@tsclass/tsclass": "^3.0.37" "@tsclass/tsclass": "^4.0.40"
}, },
"files": [ "files": [
"ts/**/*", "ts/**/*",
@ -42,5 +41,6 @@
], ],
"browserslist": [ "browserslist": [
"last 1 chrome versions" "last 1 chrome versions"
] ],
} "type": "module"
}

4481
pnpm-lock.yaml Normal file

File diff suppressed because it is too large Load Diff

View File

@ -21,7 +21,6 @@ Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](htt
PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/websetup)](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) 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) 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 ## Usage
@ -33,7 +32,6 @@ We are always happy for code contributions. If you are not the code contributing
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) ## Legal
> MIT licensed | **©** [Task Venture Capital GmbH](https://task.vc)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy)
[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com)

View File

@ -1,7 +1,7 @@
import { expect, tap, webhelpers } from '@pushrocks/tapbundle'; import { expect, tap, webhelpers } from '@pushrocks/tapbundle';
webhelpers.enable(); webhelpers.enable();
import * as websetup from '../ts/index'; import * as websetup from '../ts/index.js';
tap.test('first test', async () => { tap.test('first test', async () => {
const websetupInstance = new websetup.WebSetup({ const websetupInstance = new websetup.WebSetup({
@ -12,7 +12,7 @@ tap.test('first test', async () => {
}, },
}); });
await websetupInstance.readyPromise; await websetupInstance.readyPromise;
expect(document.title).to.equal('mytitle'); expect(document.title).toEqual('mytitle');
}); });
tap.start(); tap.start();

8
ts/00_commitinfo_data.ts Normal file
View File

@ -0,0 +1,8 @@
/**
* autocreated commitinfo by @pushrocks/commitinfo
*/
export const commitinfo = {
name: '@pushrocks/websetup',
version: '3.0.17',
description: 'setup basic page properties'
}

View File

@ -1,5 +1,5 @@
export * from './websetup.classes.websetup'; export * from './websetup.classes.websetup.js';
export * from './websetup.classes.tag.metatag'; export * from './websetup.classes.tag.metatag.js';
export * from './websetup.classes.tag.opengraphtag'; export * from './websetup.classes.tag.opengraphtag.js';
export * from './websetup.classes.tag.jsonldtag'; export * from './websetup.classes.tag.jsonldtag.js';
export * from './websetup.classes.title'; export * from './websetup.classes.title.js';

View File

@ -1,11 +1,10 @@
import * as plugins from '../websetup.plugins'; import * as plugins from '../websetup.plugins.js';
export interface IMetaObject { export interface IMetaObject {
title: string; title: string;
description?: string; description?: string;
canonicalDomain?: string; canonicalDomain?: string;
ldCompany?: plugins.tsclass.business.ICompany; ldCompany?: plugins.tsclass.business.ICompany;
ldProduct?: any; ldProduct?: plugins.tsclass.saas.IProduct;
// handles // handles
twitterHandle?: string; twitterHandle?: string;

View File

@ -1,10 +1,11 @@
import * as plugins from './websetup.plugins'; import * as plugins from './websetup.plugins.js';
import * as interfaces from './interfaces'; import * as interfaces from './interfaces/index.js';
import { Tag } from './websetup.classes.tag'; import { Tag } from './websetup.classes.tag.js';
export class JsonLdTag extends Tag { export class JsonLdTag extends Tag {
public static createCompanyLd(companyDataArg: plugins.tsclass.business.ICompany) { public static createCompanyJsonLd(companyDataArg: plugins.tsclass.business.ICompany) {
// STATIC
// lets care about linked data // lets care about linked data
const companyLd = { const companyLd = {
'@context': 'https://schema.org', '@context': 'https://schema.org',
@ -64,7 +65,37 @@ export class JsonLdTag extends Tag {
const ldTag = new JsonLdTag(newsArticleLd); const ldTag = new JsonLdTag(newsArticleLd);
return ldTag; return ldTag;
} }
public static createProductJsonLd(
productArg: plugins.tsclass.saas.IProduct,
publisherArg: plugins.tsclass.business.ICompany
) {
const productLd = {
'@context': 'https://schema.org',
'@type': 'SoftwareApplication',
name: productArg.name,
description: productArg.description,
operatingSystem: productArg.os,
applicationCategory: productArg.category,
offers: {
'@type': 'Offer',
name: 'User-based Plan',
priceSpecification: {
'@type': 'PropertyValueSpecification',
valueName: 'Number of Users',
valueRequired: true,
price: '4.99',
priceCurrency: 'EUR',
},
},
publisher: this.createCompanyJsonLd(publisherArg).elementRef.textContent,
screenshot: 'https://www.social.io/screenshot.png',
url: 'https://www.social.io/',
};
const ldTag = new JsonLdTag(productLd);
return ldTag;
}
// INSTANCE
constructor(ldObjectArg: any) { constructor(ldObjectArg: any) {
super(); super();
const jsonLdElement = document.createElement('script'); const jsonLdElement = document.createElement('script');

View File

@ -1,4 +1,4 @@
import { Tag } from './websetup.classes.tag'; import { Tag } from './websetup.classes.tag.js';
export class LinkTag extends Tag { export class LinkTag extends Tag {
constructor(relArg: string, hrefArg: string) { constructor(relArg: string, hrefArg: string) {

View File

@ -1,4 +1,4 @@
import { Tag } from './websetup.classes.tag'; import { Tag } from './websetup.classes.tag.js';
export class MetaTag extends Tag { export class MetaTag extends Tag {
constructor(metaNameArg: string, contentArg: string) { constructor(metaNameArg: string, contentArg: string) {

View File

@ -1,5 +1,5 @@
import * as plugins from './websetup.plugins'; import * as plugins from './websetup.plugins.js';
import { Tag } from './websetup.classes.tag'; import { Tag } from './websetup.classes.tag.js';
export class OpengraphTag extends Tag { export class OpengraphTag extends Tag {
public static createNewsArticleOgTags(newsArticleArg: plugins.tsclass.content.IArticle) { public static createNewsArticleOgTags(newsArticleArg: plugins.tsclass.content.IArticle) {

View File

@ -1,4 +1,4 @@
import * as plugins from './websetup.plugins'; import * as plugins from './websetup.plugins.js';
export class Tag { export class Tag {
public elementRef: Element; public elementRef: Element;

View File

@ -1,8 +1,8 @@
import { Tag } from './websetup.classes.tag'; import { Tag } from './websetup.classes.tag.js';
import { JsonLdTag } from './websetup.classes.tag.jsonldtag'; import { JsonLdTag } from './websetup.classes.tag.jsonldtag.js';
import { OpengraphTag } from './websetup.classes.tag.opengraphtag'; import { OpengraphTag } from './websetup.classes.tag.opengraphtag.js';
import { TagManager } from './websetup.classes.tagmanager'; import { TagManager } from './websetup.classes.tagmanager.js';
import * as plugins from './websetup.plugins'; import * as plugins from './websetup.plugins.js';
export type TBaseLevelType = 'global' | 'base' | 'subpage'; export type TBaseLevelType = 'global' | 'base' | 'subpage';
@ -45,7 +45,7 @@ export class TagLevel {
} }
public async addCompanyInfo(companyDataArg: plugins.tsclass.business.ICompany) { public async addCompanyInfo(companyDataArg: plugins.tsclass.business.ICompany) {
this.addTag(JsonLdTag.createCompanyLd(companyDataArg)); this.addTag(JsonLdTag.createCompanyJsonLd(companyDataArg));
// lets care about open graph // lets care about open graph
this.addTag(new OpengraphTag('og:type', 'business.business')); this.addTag(new OpengraphTag('og:type', 'business.business'));
@ -80,6 +80,10 @@ export class TagLevel {
this.addTag(OpengraphTag.createNewsArticleOgTags(articleArg)); this.addTag(OpengraphTag.createNewsArticleOgTags(articleArg));
} }
public addProductInfo(productArg: plugins.tsclass.saas.IProduct, companyArg: plugins.tsclass.business.ICompany) {
this.addTag(JsonLdTag.createProductJsonLd(productArg, companyArg));
}
public async enable() { public async enable() {
if (this.title) { if (this.title) {
document.title = this.title; document.title = this.title;

View File

@ -1,9 +1,9 @@
import { TagLevel } from './websetup.classes.taglevel'; import { TagLevel } from './websetup.classes.taglevel.js';
import * as plugins from './websetup.plugins'; import * as plugins from './websetup.plugins.js';
import * as interfaces from './interfaces'; import * as interfaces from './interfaces/index.js';
import { MetaTag } from './websetup.classes.tag.metatag'; import { MetaTag } from './websetup.classes.tag.metatag.js';
import { JsonLdTag } from './websetup.classes.tag.jsonldtag'; import { JsonLdTag } from './websetup.classes.tag.jsonldtag.js';
import { OpengraphTag } from './websetup.classes.tag.opengraphtag'; import { OpengraphTag } from './websetup.classes.tag.opengraphtag.js';
export class TagManager { export class TagManager {
public globalLevel: TagLevel = new TagLevel(this, 'global'); public globalLevel: TagLevel = new TagLevel(this, 'global');
@ -33,9 +33,17 @@ export class TagManager {
this.baseLevel.addTag(new MetaTag('canonical', metaObjectArg.canonicalDomain)); this.baseLevel.addTag(new MetaTag('canonical', metaObjectArg.canonicalDomain));
} }
if (metaObjectArg.ldCompany) {
this.baseLevel.addCompanyInfo(metaObjectArg.ldCompany); // json ld
switch (true) {
case metaObjectArg.ldCompany && !metaObjectArg.ldProduct:
this.baseLevel.addCompanyInfo(metaObjectArg.ldCompany);
break;
case !!metaObjectArg.ldProduct:
this.baseLevel.addProductInfo(metaObjectArg.ldProduct, metaObjectArg.ldCompany);
break;
} }
await this.globalLevel.enable(); await this.globalLevel.enable();
this.activeLevel = this.baseLevel; this.activeLevel = this.baseLevel;
await this.activeLevel.enable(); await this.activeLevel.enable();

View File

@ -1,9 +1,7 @@
import * as plugins from './websetup.plugins'; import * as plugins from './websetup.plugins.js';
/** /**
* a title proxy class * a title proxy class
* --> to be used in the future when flashing titles is supported * --> to be used in the future when flashing titles is supported
*/ */
export class Title { export class Title {}
}

View File

@ -1,7 +1,7 @@
import * as plugins from './websetup.plugins'; import * as plugins from './websetup.plugins.js';
import * as interfaces from './interfaces'; import * as interfaces from './interfaces/index.js';
import { TagManager } from './websetup.classes.tagmanager'; import { TagManager } from './websetup.classes.tagmanager.js';
import { TagLevel } from './websetup.classes.taglevel'; import { TagLevel } from './websetup.classes.taglevel.js';
export interface IWebSetupConstructorOptions { export interface IWebSetupConstructorOptions {
metaObject: interfaces.IMetaObject; metaObject: interfaces.IMetaObject;
@ -14,7 +14,7 @@ export interface IWebSetupConstructorOptions {
export class WebSetup { export class WebSetup {
public tagManager: TagManager = new TagManager(); public tagManager: TagManager = new TagManager();
public options: IWebSetupConstructorOptions; public options: IWebSetupConstructorOptions;
// private deferreds // private deferreds
private readyDeferred = plugins.smartpromise.defer(); private readyDeferred = plugins.smartpromise.defer();
private readyForSmartssrDeferred = plugins.smartpromise.defer(); private readyForSmartssrDeferred = plugins.smartpromise.defer();
@ -69,7 +69,9 @@ export class WebSetup {
*/ */
public informReadyForSmartssr() { public informReadyForSmartssr() {
if (!this.options.smartssrWaitForReadySignal) { if (!this.options.smartssrWaitForReadySignal) {
console.error(`You have not indicated that you inform smartssr by a dedicated signal! Please consider doing so!`); console.error(
`You have not indicated that you inform smartssr by a dedicated signal! Please consider doing so!`
);
} }
this.readyForSmartssrDeferred.resolve(); this.readyForSmartssrDeferred.resolve();
} }

10
tsconfig.json Normal file
View File

@ -0,0 +1,10 @@
{
"compilerOptions": {
"experimentalDecorators": true,
"useDefineForClassFields": false,
"target": "ES2022",
"module": "ES2022",
"moduleResolution": "nodenext",
"esModuleInterop": true
}
}

View File

@ -1,17 +0,0 @@
{
"extends": ["tslint:latest", "tslint-config-prettier"],
"rules": {
"semicolon": [true, "always"],
"no-console": false,
"ordered-imports": false,
"object-literal-sort-keys": false,
"member-ordering": {
"options":{
"order": [
"static-method"
]
}
}
},
"defaultSeverity": "warning"
}