fix(core): update

This commit is contained in:
Philipp Kunz 2021-01-27 21:00:49 +00:00
parent 211529ffff
commit 39ef242615
12 changed files with 10342 additions and 836 deletions

4
.gitignore vendored
View File

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

View File

@ -4,7 +4,7 @@ image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache: cache:
paths: paths:
- .npmci_cache/ - .npmci_cache/
key: "$CI_BUILD_STAGE" key: '$CI_BUILD_STAGE'
stages: stages:
- security - security
@ -19,20 +19,35 @@ mirror:
stage: security stage: security
script: script:
- npmci git mirror - npmci git mirror
only:
- tags
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
snyk: auditProductionDependencies:
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
stage: security stage: security
script: script:
- npmci npm prepare - npmci npm prepare
- npmci command npm install -g snyk - npmci command npm install --production --ignore-scripts
- npmci command npm install --ignore-scripts - npmci command npm config set registry https://registry.npmjs.org
- npmci command snyk test - npmci command npm audit --audit-level=high --only=prod --production
tags: tags:
- docker - docker
- notpriv
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 # test stage
@ -48,7 +63,6 @@ testStable:
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- priv
testBuild: testBuild:
stage: test stage: test
@ -60,7 +74,6 @@ testBuild:
coverage: /\d+.?\d+?\%\s*coverage/ coverage: /\d+.?\d+?\%\s*coverage/
tags: tags:
- docker - docker
- notpriv
release: release:
stage: release stage: release
@ -70,6 +83,7 @@ release:
only: only:
- tags - tags
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
@ -79,11 +93,15 @@ release:
codequality: codequality:
stage: metadata stage: metadata
allow_failure: true allow_failure: true
only:
- tags
script: script:
- npmci command npm install -g tslint typescript - npmci command npm install -g tslint typescript
- npmci npm prepare
- npmci npm install - npmci npm install
- npmci command "tslint -c tslint.json ./ts/**/*.ts" - npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags: tags:
- lossless
- docker - docker
- priv - priv
@ -94,20 +112,20 @@ trigger:
only: only:
- tags - tags
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
pages: pages:
image: hosttoday/ht-docker-dbase:npmci
services:
- docker:stable-dind
stage: metadata stage: metadata
script: script:
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc - npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare - npmci npm prepare
- npmci npm install - npmci npm install
- npmci command tsdoc - npmci command tsdoc
tags: tags:
- lossless
- docker - docker
- notpriv - notpriv
only: only:

29
.vscode/launch.json vendored Normal file
View File

@ -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"
}
]
}

26
.vscode/settings.json vendored Normal file
View File

@ -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"]
}
}
}
}
}
}
]
}

View File

@ -1,61 +0,0 @@
# @pushrocks/npmextra
do more with npm
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/npmextra)
* [gitlab.com (source)](https://gitlab.com/pushrocks/npmextra)
* [github.com (source mirror)](https://github.com/pushrocks/npmextra)
* [docs (typedoc)](https://pushrocks.gitlab.io/npmextra/)
## Status for master
[![build status](https://gitlab.com/pushrocks/npmextra/badges/master/build.svg)](https://gitlab.com/pushrocks/npmextra/commits/master)
[![coverage report](https://gitlab.com/pushrocks/npmextra/badges/master/coverage.svg)](https://gitlab.com/pushrocks/npmextra/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@pushrocks/npmextra.svg)](https://www.npmjs.com/package/@pushrocks/npmextra)
[![Known Vulnerabilities](https://snyk.io/test/npm/@pushrocks/npmextra/badge.svg)](https://snyk.io/test/npm/@pushrocks/npmextra)
[![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.
## Using npmextra for managing toolconfigs
The main purpose of npmextra is to configure different tools using one npmextra.json. This way complex setups avoid additional complexity caused by too many configuration files.
npmextra.json
```json
{
"sometool": {
"defaultKey1": "awesomeValueFromConfig"
}
}
```
```typescript
import { Npmextra } from 'npmextra';
let myNpmExtra = new Npmextra('my/path/to/cwd'); // cwd argument is optional
mergedData = myNpmExtra.dataFor('sometool', {
// gets merged with whatever is in the configfile
defaultKey1: 'defaultValue1', // so this will get overwritten with "awesomeValueFromConfig"
defaultKey2: 'defaultValue2' // this one will pass through unaltered
});
```
### Tools that already use the config feature of npmextra
- [npmts](https://www.npmjs.com/package/npmts)
- [npmci](https://www.npmjs.com/package/npmci)
- [npmdocker](https://www.npmjs.com/package/npmdocker)
## Using the KeyValueStore
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)

View File

@ -9,6 +9,7 @@
} }
}, },
"gitzone": { "gitzone": {
"projectType": "npm",
"module": { "module": {
"githost": "gitlab.com", "githost": "gitlab.com",
"gitscope": "pushrocks", "gitscope": "pushrocks",

10921
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -3,8 +3,8 @@
"version": "3.0.7", "version": "3.0.7",
"private": false, "private": false,
"description": "do more with npm", "description": "do more with npm",
"main": "dist/index.js", "main": "dist_ts/index.js",
"typings": "dist/index.d.ts", "typings": "dist_ts/index.d.ts",
"scripts": { "scripts": {
"test": "(tstest test/)", "test": "(tstest test/)",
"build": "(tsbuild)" "build": "(tsbuild)"
@ -20,30 +20,34 @@
}, },
"homepage": "https://gitlab.com/pushrocks/npmextra#README", "homepage": "https://gitlab.com/pushrocks/npmextra#README",
"dependencies": { "dependencies": {
"@pushrocks/smartfile": "^7.0.4", "@pushrocks/smartfile": "^8.0.8",
"@pushrocks/smartlog": "^2.0.19", "@pushrocks/smartlog": "^2.0.39",
"@pushrocks/smartpath": "^4.0.1", "@pushrocks/smartpath": "^4.0.3",
"@pushrocks/smartpromise": "^3.0.5", "@pushrocks/smartpromise": "^3.1.3",
"@pushrocks/taskbuffer": "^2.0.10" "@pushrocks/taskbuffer": "^2.1.13"
}, },
"devDependencies": { "devDependencies": {
"@gitzone/tsbuild": "^2.1.17", "@gitzone/tsbuild": "^2.1.25",
"@gitzone/tsrun": "^1.2.8", "@gitzone/tsrun": "^1.2.12",
"@gitzone/tstest": "^1.0.24", "@gitzone/tstest": "^1.0.52",
"@pushrocks/tapbundle": "^3.0.13", "@pushrocks/tapbundle": "^3.2.10",
"@types/node": "^12.7.5", "@types/node": "^14.14.22",
"tslint": "^5.20.0", "tslint": "^6.1.3",
"tslint-config-prettier": "^1.18.0" "tslint-config-prettier": "^1.18.0"
}, },
"files": [ "files": [
"ts/*", "ts/**/*",
"ts_web/*", "ts_web/**/*",
"dist/*", "dist/**/*",
"dist_web/*", "dist_*/**/*",
"dist_ts_web/*", "dist_ts/**/*",
"assets/*", "dist_ts_web/**/*",
"assets/**/*",
"cli.js", "cli.js",
"npmextra.json", "npmextra.json",
"readme.md" "readme.md"
],
"browserslist": [
"last 1 chrome versions"
] ]
} }

View File

@ -17,7 +17,7 @@ tap.test('expect result to be empty', async () => {
tap.test('expect to add an object to the kv Store', async () => { tap.test('expect to add an object to the kv Store', async () => {
await myKeyValueStore.writeAll({ await myKeyValueStore.writeAll({
myKey: 'myValue' myKey: 'myValue',
}); });
await expect(myKeyValueStore.readKey('myKey')).to.eventually.equal('myValue'); await expect(myKeyValueStore.readKey('myKey')).to.eventually.equal('myValue');
}); });

View File

@ -24,7 +24,7 @@ tap.test('should pass through default value, if not overriden by config from fil
tap.test('should read a config file', async () => { tap.test('should read a config file', async () => {
let testData = testNpmextra.dataFor<any>('testTool', { let testData = testNpmextra.dataFor<any>('testTool', {
someKey2: 'someValue2' someKey2: 'someValue2',
}); });
expect(testData).have.ownProperty('someKey2'); expect(testData).have.ownProperty('someKey2');
expect(testData.testValue).equal(2); expect(testData.testValue).equal(2);

View File

@ -14,19 +14,19 @@ export class KeyValueStore {
public syncTask = new Task({ public syncTask = new Task({
name: 'syncTask', name: 'syncTask',
buffered: true, buffered: true,
bufferMax: 2, bufferMax: 1,
execDelay: 500, execDelay: 0,
taskFunction: async () => { taskFunction: async () => {
this.dataObject = { this.dataObject = {
...plugins.smartfile.fs.toObjectSync(this.filePath), ...plugins.smartfile.fs.toObjectSync(this.filePath),
...this.dataObject ...this.dataObject,
}; };
for (const key of Object.keys(this.deletedObject)) { for (const key of Object.keys(this.deletedObject)) {
delete this.dataObject[key]; delete this.dataObject[key];
} }
this.deletedObject = {}; this.deletedObject = {};
await plugins.smartfile.memory.toFs(JSON.stringify(this.dataObject), this.filePath); await plugins.smartfile.memory.toFs(JSON.stringify(this.dataObject), this.filePath);
} },
}); });
/** /**
* computes the identity * computes the identity
@ -85,7 +85,7 @@ export class KeyValueStore {
*/ */
public async writeKey(keyArg: string, valueArg: any) { public async writeKey(keyArg: string, valueArg: any) {
await this.writeAll({ await this.writeAll({
[keyArg]: valueArg [keyArg]: valueArg,
}); });
} }

View File

@ -36,7 +36,7 @@ export class Npmextra {
} }
let mergedOptions = { let mergedOptions = {
...defaultOptionsArg, ...defaultOptionsArg,
...npmextraToolOptions ...npmextraToolOptions,
}; };
return mergedOptions; return mergedOptions;
} }