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..69b3e08 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,29 +12,35 @@ stages: - release - metadata +before_script: + - npm install -g @shipzone/npmci + # ==================== # security stage # ==================== -mirror: +auditProductionDependencies: + image: registry.gitlab.com/hosttoday/ht-docker-node:npmci stage: security script: - - npmci git mirror + - 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 tags: - - lossless - docker - - notpriv + allow_failure: true -snyk: - image: registry.gitlab.com/hosttoday/ht-docker-node:snyk +auditDevDependencies: + 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 --only=dev tags: - - lossless - docker - - notpriv + allow_failure: true # ==================== # test stage @@ -49,9 +55,7 @@ testStable: - npmci npm test coverage: /\d+.?\d+?\%\s*coverage/ tags: - - lossless - docker - - priv testBuild: stage: test @@ -62,9 +66,7 @@ testBuild: - npmci command npm run build coverage: /\d+.?\d+?\%\s*coverage/ tags: - - lossless - docker - - notpriv release: stage: release @@ -84,11 +86,12 @@ release: codequality: stage: metadata allow_failure: true + 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 @@ -108,11 +111,10 @@ trigger: pages: stage: metadata script: - - npmci node install lts - - npmci command npm install -g @gitzone/tsdoc + - npmci node install stable - npmci npm prepare - npmci npm install - - npmci command tsdoc + - npmci command npm run buildDocs tags: - lossless - docker diff --git a/.vscode/launch.json b/.vscode/launch.json index 112db52..26e9f92 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -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" } ] } 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/npmextra.json b/npmextra.json index 229baf6..54f4d7b 100644 --- a/npmextra.json +++ b/npmextra.json @@ -5,7 +5,7 @@ "githost": "gitlab.com", "gitscope": "pushrocks", "gitrepo": "smartrule", - "shortDescription": "a smart rule library for handling decision trees.", + "description": "a smart rule library for handling decision trees.", "npmPackagename": "@pushrocks/smartrule", "license": "MIT", "projectDomain": "push.rocks" diff --git a/package.json b/package.json index ef3d5a4..fba6bdd 100644 --- a/package.json +++ b/package.json @@ -3,15 +3,16 @@ "version": "2.0.0", "private": false, "description": "a smart rule library for handling decision trees.", - "main": "dist/index.js", - "typings": "dist/index.d.ts", + "main": "dist_ts/index.js", + "typings": "dist_ts/index.d.ts", "type": "module", "author": "Lossless GmbH", "license": "MIT", "scripts": { "test": "(tstest test/)", "build": "(tsbuild --web)", - "format": "(gitzone format)" + "format": "(gitzone format)", + "buildDocs": "tsdoc" }, "devDependencies": { "@gitzone/tsbuild": "^2.1.65", @@ -23,11 +24,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 fe1a29f..a454d6b 100644 --- a/readme.md +++ b/readme.md @@ -8,13 +8,20 @@ a smart rule library for handling decision trees. * [docs (typedoc)](https://pushrocks.gitlab.io/smartrule/) ## Status for master -[![pipeline status](https://gitlab.com/pushrocks/smartrule/badges/master/pipeline.svg)](https://gitlab.com/pushrocks/smartrule/commits/master) -[![coverage report](https://gitlab.com/pushrocks/smartrule/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartrule/commits/master) -[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartrule.svg)](https://www.npmjs.com/package/@pushrocks/smartrule) -[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartrule/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartrule) -[![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/smartrule/badges/master/pipeline.svg)](https://lossless.cloud) +GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartrule/badges/master/coverage.svg)](https://lossless.cloud) +npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartrule)](https://lossless.cloud) +Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartrule)](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/smartrule)](https://lossless.cloud) +PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartrule)](https://lossless.cloud) +BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartrule)](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 b9eb19c..6bc0f38 100644 --- a/test/test.ts +++ b/test/test.ts @@ -12,12 +12,12 @@ tap.test('first test', async () => { testSmartruleInstance = new smartrule.SmartRule(); testSmartruleInstance.createRule( 2, - async messageArg => { + async (messageArg) => { if (messageArg.body.startsWith('hello')) { return 'apply-stop'; } }, - async messageArg => { + async (messageArg) => { console.log(`rule triggered for message with body ${messageArg.body}`); } ); @@ -26,7 +26,7 @@ tap.test('first test', async () => { tap.test('make a decision based on an object', async () => { testSmartruleInstance.makeDecision({ id: '123456', - body: 'hello, there. This is a cool message!' + body: 'hello, there. This is a cool message!', }); }); diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index a389d3d..5451b14 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@pushrocks/smartrule', - version: '2.0.0', + version: '2.0.1', description: 'a smart rule library for handling decision trees.' } diff --git a/ts/smartrule.classes.smartrule.ts b/ts/smartrule.classes.smartrule.ts index e9dcb1a..9ed9973 100644 --- a/ts/smartrule.classes.smartrule.ts +++ b/ts/smartrule.classes.smartrule.ts @@ -20,7 +20,7 @@ export class SmartRule { // gets the next batch with the same priority const getNextParallelBatch = (priorityStart: number) => { - return this.rules.filter(rule => { + return this.rules.filter((rule) => { return rule.priority === priorityStart; }); };