fix(core): update

This commit is contained in:
Philipp Kunz 2019-11-03 00:49:35 +01:00
parent cc7eb8c139
commit 1dbf3724d0
7 changed files with 130 additions and 89 deletions

19
.gitignore vendored
View File

@ -1,5 +1,22 @@
.nogit/
node_modules/
# artifacts
coverage/
public/
pages/
# installs
node_modules/
# caches
.yarn/
.cache/
.rpt2_cache
# builds
dist/
dist_web/
dist_serve/
dist_ts_web/
# custom

View File

@ -1,16 +1,16 @@
# gitzone standard
image: hosttoday/ht-docker-node:npmci
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
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
@ -18,10 +18,11 @@ stages:
mirror:
stage: security
script:
- npmci git mirror
- npmci git mirror
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
snyk:
stage: security
@ -31,89 +32,89 @@ snyk:
- npmci command npm install --ignore-scripts
- npmci command snyk test
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
# ====================
# test stage
# ====================
testLTS:
testStable:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- 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
- notpriv
testSTABLE:
- lossless
- docker
- priv
testBuild:
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 command npm run build
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
release:
stage: release
script:
- npmci node install stable
- npmci npm publish
- npmci node install stable
- npmci npm publish
only:
- tags
- tags
tags:
- docker
- notpriv
- lossless
- docker
- notpriv
# ====================
# metadata stage
# ====================
codequality:
stage: metadata
image: docker:stable
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 SOURCE_CODE="$PWD"
--volume "$PWD":/code
--volume /var/run/docker.sock:/var/run/docker.sock
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
artifacts:
paths: [codeclimate.json]
- 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-node:npmci
stage: metadata
script:
- npmci command npm install -g typedoc typescript
- npmci node install lts
- npmci command npm install -g @gitzone/tsdoc
- npmci npm prepare
- npmci npm install
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
- npmci command tsdoc
tags:
- lossless
- docker
- notpriv
only:
@ -121,5 +122,5 @@ pages:
artifacts:
expire_in: 1 week
paths:
- public
- public
allow_failure: true

View File

@ -2,5 +2,15 @@
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"module": {
"githost": "gitlab.com",
"gitscope": "mojoio",
"gitrepo": "elasticsearch",
"shortDescription": "log to elasticsearch in a kibana compatible format",
"npmPackagename": "@mojoio/elasticsearch",
"license": "MIT"
}
}
}
}

View File

@ -30,5 +30,16 @@
"@pushrocks/smarttime": "^3.0.12",
"@types/elasticsearch": "^5.0.35",
"elasticsearch": "^16.5.0"
}
}
},
"files": [
"ts/**/*",
"ts_web/**/*",
"dist/**/*",
"dist_web/**/*",
"dist_ts_web/**/*",
"assets/**/*",
"cli.js",
"npmextra.json",
"readme.md"
]
}

View File

@ -1,26 +1,20 @@
# elasticlog
# @mojoio/elasticsearch
log to elasticsearch in a kibana compatible format
## Availabililty
[![npm](https://pushrocks.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/elasticlog)
[![git](https://pushrocks.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/pushrocks/elasticlog)
[![git](https://pushrocks.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/pushrocks/elasticlog)
[![docs](https://pushrocks.gitlab.io/assets/repo-button-docs.svg)](https://pushrocks.gitlab.io/elasticlog/)
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@mojoio/elasticsearch)
* [gitlab.com (source)](https://gitlab.com/mojoio/elasticsearch)
* [github.com (source mirror)](https://github.com/mojoio/elasticsearch)
* [docs (typedoc)](https://mojoio.gitlab.io/elasticsearch/)
## Status for master
[![build status](https://GitLab.com/pushrocks/elasticlog/badges/master/build.svg)](https://GitLab.com/pushrocks/elasticlog/commits/master)
[![coverage report](https://GitLab.com/pushrocks/elasticlog/badges/master/coverage.svg)](https://GitLab.com/pushrocks/elasticlog/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/elasticlog.svg)](https://www.npmjs.com/package/elasticlog)
[![Dependency Status](https://david-dm.org/pushrocks/elasticlog.svg)](https://david-dm.org/pushrocks/elasticlog)
[![bitHound Dependencies](https://www.bithound.io/github/pushrocks/elasticlog/badges/dependencies.svg)](https://www.bithound.io/github/pushrocks/elasticlog/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/pushrocks/elasticlog/badges/code.svg)](https://www.bithound.io/github/pushrocks/elasticlog)
[![Known Vulnerabilities](https://snyk.io/test/npm/elasticlog/badge.svg)](https://snyk.io/test/npm/elasticlog)
[![TypeScript](https://img.shields.io/badge/TypeScript-2.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![node](https://img.shields.io/badge/node->=%206.x.x-blue.svg)](https://nodejs.org/dist/latest-v6.x/docs/api/)
[![JavaScript Style Guide](https://img.shields.io/badge/code%20style-standard-brightgreen.svg)](http://standardjs.com/)
[![build status](https://gitlab.com/mojoio/elasticsearch/badges/master/build.svg)](https://gitlab.com/mojoio/elasticsearch/commits/master)
[![coverage report](https://gitlab.com/mojoio/elasticsearch/badges/master/coverage.svg)](https://gitlab.com/mojoio/elasticsearch/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@mojoio/elasticsearch.svg)](https://www.npmjs.com/package/@mojoio/elasticsearch)
[![Known Vulnerabilities](https://snyk.io/test/npm/@mojoio/elasticsearch/badge.svg)](https://snyk.io/test/npm/@mojoio/elasticsearch)
[![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
@ -32,3 +26,14 @@ For further information read the linked docs at the top of this README.
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://pushrocks.gitlab.io/assets/repo-footer.svg)](https://push.rocks)
## Contribute
We are always happy for code contributions. If you are not the code contributing type that is ok. + Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: [Contribute monthly :)](https://lossless.link/contribute)
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

@ -24,13 +24,13 @@ export class ElasticIndex {
bytes: 'm'
},
async (err, responseArg: any[]) => {
if(err) {
if (err) {
console.log(err);
return;
}
// lets delete indexes that violate the retention
if(Array.isArray(responseArg)) {
if (Array.isArray(responseArg)) {
const filteredIndices = responseArg.filter(indexObjectArg => {
return indexObjectArg.index.startsWith('smartlog');
});
@ -41,8 +41,8 @@ export class ElasticIndex {
}
let index = null;
if(Array.isArray(responseArg)) {
if (Array.isArray(responseArg)) {
index = responseArg.find(indexObject => {
return indexObject.index === indexArg;
});
@ -52,7 +52,6 @@ export class ElasticIndex {
const done2 = plugins.smartpromise.defer();
this.elasticSearchRef.client.indices.create(
{
waitForActiveShards: '1',
index: indexArg
},
@ -70,15 +69,13 @@ export class ElasticIndex {
await done.promise;
}
public createNewIndex(indexNameArg: string) {
}
public createNewIndex(indexNameArg: string) {}
public async deleteOldIndices(indicesArray: string[]) {
const todayAsUnix: number = Date.now();
const rententionPeriodAsUnix: number = plugins.smarttime.units.days(
this.elasticSearchRef.indexRetention
);
const rententionPeriodAsUnix: number = plugins.smarttime.units.days(
this.elasticSearchRef.indexRetention
);
for (const indexName of indicesArray) {
const regexResult = /^smartlog-([0-9]*)\.([0-9]*)\.([0-9]*)$/.exec(indexName);
const dateAsUnix: number = new Date(

View File

@ -35,7 +35,7 @@ export class ElasticSearch<T> {
*/
constructor(optionsArg: IElasticSearchConstructorOptions) {
this.client = new ElasticClient({
host: this.computeHostString(optionsArg),
host: this.computeHostString(optionsArg)
// log: 'trace'
});
this.indexPrefix = optionsArg.indexPrefix;