From 0d3bcab40f1dbeac642bcff1075d3ea502178d87 Mon Sep 17 00:00:00 2001 From: Phil Kunz Date: Mon, 5 Oct 2020 11:26:06 +0000 Subject: [PATCH] fix(core): update --- .gitignore | 4 +- .gitlab-ci.yml | 104 +++++++++++++++++++++++----------------- .vscode/launch.json | 29 +++++++++++ .vscode/settings.json | 26 ++++++++++ README.md | 53 -------------------- package.json | 18 ++++--- test/test.ts | 8 +--- ts/index.ts | 2 +- ts/smartjson.plugins.ts | 14 ++++-- 9 files changed, 140 insertions(+), 118 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json delete mode 100644 README.md 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 a6159b7..9a4467e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,18 +1,16 @@ # gitzone ci_default image: registry.gitlab.com/hosttoday/ht-docker-node:npmci -variables: - GIT_STRATEGY: clone cache: paths: - - .npmci_cache/ - key: "$CI_BUILD_STAGE" + - .npmci_cache/ + key: '$CI_BUILD_STAGE' stages: -- security -- test -- release -- metadata + - security + - test + - release + - metadata # ==================== # security stage @@ -20,21 +18,36 @@ stages: mirror: stage: security script: - - npmci git mirror + - npmci git mirror + only: + - tags tags: - - docker - - notpriv + - lossless + - docker + - notpriv -snyk: +auditProductionDependencies: + image: registry.gitlab.com/hosttoday/ht-docker-node:npmci stage: security script: - npmci npm prepare - - npmci command npm install -g snyk - - npmci command npm install --ignore-scripts - - npmci command snyk test + - 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: - - docker - - notpriv + - docker + +auditDevDependencies: + image: registry.gitlab.com/hosttoday/ht-docker-node:npmci + stage: security + script: + - npmci npm prepare + - npmci command npm install --ignore-scripts + - npmci command npm config set registry https://registry.npmjs.org + - npmci command npm audit --audit-level=high --only=dev + tags: + - docker + allow_failure: true # ==================== # test stage @@ -43,37 +56,36 @@ snyk: testStable: stage: test script: - - npmci npm prepare - - npmci node install stable - - npmci npm install - - npmci npm test + - npmci npm prepare + - npmci node install stable + - npmci npm install + - npmci npm test coverage: /\d+.?\d+?\%\s*coverage/ tags: - - docker - - priv + - docker testBuild: stage: test script: - - npmci npm prepare - - npmci node install lts - - npmci npm install - - npmci command npm run build + - npmci npm prepare + - npmci node install stable + - npmci npm install + - npmci command npm run build coverage: /\d+.?\d+?\%\s*coverage/ tags: - - docker - - notpriv + - docker release: stage: release script: - - npmci node install lts - - npmci npm publish + - npmci node install stable + - npmci npm publish only: - - tags + - tags tags: - - docker - - notpriv + - lossless + - docker + - notpriv # ==================== # metadata stage @@ -81,35 +93,39 @@ release: codequality: stage: metadata allow_failure: true + only: + - tags script: - npmci command npm install -g tslint typescript + - npmci npm prepare - npmci npm install - npmci command "tslint -c tslint.json ./ts/**/*.ts" tags: - - docker - - priv + - lossless + - docker + - priv trigger: stage: metadata script: - - npmci trigger + - npmci trigger only: - - tags + - tags tags: - - docker - - notpriv + - lossless + - docker + - notpriv pages: - image: hosttoday/ht-docker-dbase:npmci - services: - - docker:18-dind stage: metadata script: + - npmci node install lts - npmci command npm install -g @gitzone/tsdoc - npmci npm prepare - npmci npm install - npmci command tsdoc tags: + - lossless - docker - notpriv only: @@ -117,5 +133,5 @@ pages: artifacts: expire_in: 1 week paths: - - public + - public allow_failure: true diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000..112db52 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,29 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": "current file", + "type": "node", + "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" + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..3648eaa --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,26 @@ +{ + "json.schemas": [ + { + "fileMatch": ["/npmextra.json"], + "schema": { + "type": "object", + "properties": { + "npmci": { + "type": "object", + "description": "settings for npmci" + }, + "gitzone": { + "type": "object", + "description": "settings for gitzone", + "properties": { + "projectType": { + "type": "string", + "enum": ["website", "element", "service", "npm", "wcc"] + } + } + } + } + } + } + ] +} diff --git a/README.md b/README.md deleted file mode 100644 index f46c2b7..0000000 --- a/README.md +++ /dev/null @@ -1,53 +0,0 @@ -# @pushrocks/smartjson -typed json handlers - -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartjson) -* [gitlab.com (source)](https://gitlab.com/pushrocks/smartjson) -* [github.com (source mirror)](https://github.com/pushrocks/smartjson) -* [docs (typedoc)](https://pushrocks.gitlab.io/smartjson/) - -## Status for master -[![build status](https://gitlab.com/pushrocks/smartjson/badges/master/build.svg)](https://gitlab.com/pushrocks/smartjson/commits/master) -[![coverage report](https://gitlab.com/pushrocks/smartjson/badges/master/coverage.svg)](https://gitlab.com/pushrocks/smartjson/commits/master) -[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/smartjson.svg)](https://www.npmjs.com/package/@pushrocks/smartjson) -[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/smartjson/badge.svg)](https://snyk.io/test/npm/@pushrocks/smartjson) -[![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/) - -## Usage - -Use TypeScript for best in class instellisense. - -### Classes - -SmartJson makes it easy to fold and enfold classes into and from JSON - -```javascript -import { Smartjson, foldDec } from 'smartjson'; - -class AwesomeClass extends Smartjson { - static stringify; - - computedValue: string; - - @foldDec() // mark anotherValueToStore as foldable - anotherValueToStore: string = null; - constructor() { - super(); // this is important - } -} - -let myAwesomeInstance = new AwesomeClass(); -let foldedObject = myAwesomeInstance.foldToObject(); // will return {anotherValueToStore: null} -myAwesomeInstance.enfoldFromObject({ anotherValueToStore: 'hi' }); -foldedObject = myAwesomeInstance.foldToObject(); // will return {anotherValueToStore: 'hi'} -``` - -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) - -[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com) diff --git a/package.json b/package.json index fe98def..272e83d 100644 --- a/package.json +++ b/package.json @@ -36,14 +36,18 @@ "lodash.clonedeep": "^4.5.0" }, "files": [ - "ts/*", - "ts_web/*", - "dist/*", - "dist_web/*", - "dist_ts_web/*", - "assets/*", + "ts/**/*", + "ts_web/**/*", + "dist/**/*", + "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/test/test.ts b/test/test.ts index 628ef63..9825d56 100644 --- a/test/test.ts +++ b/test/test.ts @@ -20,16 +20,12 @@ tap.test('should create a Foldable extended instance', async () => { tap.test('should create a folded object', async () => { let foldedObject = mySomeClass.foldToObject(); - expect(foldedObject) - .property('thisis') - .to.equal('test'); + expect(foldedObject).property('thisis').to.equal('test'); }); tap.test('should enfold from object', async () => { const mySomeClass2 = SomeClass.enfoldFromObject({ thisis: 'test2' }); - expect(mySomeClass2) - .property('thisis') - .to.equal('test2'); + expect(mySomeClass2).property('thisis').to.equal('test2'); }); tap.start(); diff --git a/ts/index.ts b/ts/index.ts index 66a6966..63b7e65 100644 --- a/ts/index.ts +++ b/ts/index.ts @@ -6,7 +6,7 @@ import * as plugins from './smartjson.plugins'; export const parse = plugins.bufferJson.parse; /** - * + * * @param objArg * @param optionsArg */ diff --git a/ts/smartjson.plugins.ts b/ts/smartjson.plugins.ts index 3ed4b5c..4f2bc7d 100644 --- a/ts/smartjson.plugins.ts +++ b/ts/smartjson.plugins.ts @@ -8,13 +8,19 @@ const stableJson = stableJson2 as any; export { bufferJson, lodashCloneDeep, stableJson }; export interface IStableJsonTypes { - Comparator: (a: IStableJsonTypes['CompareDescriptor'], b: IStableJsonTypes['CompareDescriptor']) => number; + Comparator: ( + a: IStableJsonTypes['CompareDescriptor'], + b: IStableJsonTypes['CompareDescriptor'] + ) => number; CompareDescriptor: { - key: string; - value: any; + key: string; + value: any; }; Options: { - cmp?: (a: IStableJsonTypes['CompareDescriptor'], b: IStableJsonTypes['CompareDescriptor']) => number; + cmp?: ( + a: IStableJsonTypes['CompareDescriptor'], + b: IStableJsonTypes['CompareDescriptor'] + ) => number; cycles?: boolean; }; }