fix(core): update

This commit is contained in:
Philipp Kunz 2019-09-05 13:08:42 +02:00
parent 55e75766b7
commit eeb1a99884
12 changed files with 1102 additions and 343 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,5 +1,5 @@
# gitzone standard
image: hosttoday/ht-docker-node:npmci
# gitzone ci_default
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
cache:
paths:
@ -26,6 +26,7 @@ mirror:
snyk:
stage: security
script:
- npmci npm prepare
- npmci command npm install -g snyk
- npmci command npm install --ignore-scripts
- npmci command snyk test
@ -36,21 +37,11 @@ snyk:
# ====================
# test stage
# ====================
testLEGACY:
stage: test
script:
- npmci node install legacy
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
allow_failure: true
testLTS:
stage: test
script:
- npmci npm prepare
- npmci node install lts
- npmci npm install
- npmci npm test
@ -58,22 +49,11 @@ testLTS:
tags:
- docker
- notpriv
testSTABLE:
stage: test
script:
- npmci node install stable
- npmci npm install
- npmci npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- docker
- notpriv
release:
stage: release
script:
- npmci node install stable
- npmci node install lts
- npmci npm publish
only:
- tags
@ -86,19 +66,11 @@ release:
# ====================
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 install
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
tags:
- docker
- priv
@ -117,9 +89,10 @@ pages:
image: hosttoday/ht-docker-node:npmci
stage: metadata
script:
- npmci command npm install -g typedoc typescript
- 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:
- docker
- notpriv
@ -130,13 +103,3 @@ pages:
paths:
- public
allow_failure: true
windowsCompatibility:
image: stefanscherer/node-windows:10-build-tools
stage: metadata
script:
- npm install & npm test
coverage: /\d+.?\d+?\%\s*coverage/
tags:
- windows
allow_failure: true

View File

@ -2,5 +2,15 @@
"npmci": {
"npmGlobalTools": [],
"npmAccessLevel": "public"
},
"gitzone": {
"module": {
"githost": "gitlab.com",
"gitscope": "mojoio",
"gitrepo": "slack",
"shortDescription": "slack api abstraction for the mojo.io ecosystem",
"npmPackagename": "@mojoio/slack",
"license": "MIT"
}
}
}
}

1188
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,7 +2,7 @@
"name": "@mojoio/slack",
"version": "2.0.6",
"private": false,
"description": "API abstraction for mojoio",
"description": "slack api abstraction for the mojo.io ecosystem",
"main": "dist/index.js",
"typings": "dist/index.d.ts",
"author": "Lossless GmbH",
@ -12,14 +12,24 @@
"build": "tsbuild"
},
"devDependencies": {
"@gitzone/tsbuild": "^2.0.22",
"@gitzone/tsrun": "^1.1.12",
"@gitzone/tstest": "^1.0.15",
"@pushrocks/qenv": "^2.0.2",
"@pushrocks/tapbundle": "^3.0.7",
"@types/node": "^10.11.4"
"@gitzone/tsbuild": "^2.1.17",
"@gitzone/tsrun": "^1.2.8",
"@gitzone/tstest": "^1.0.24",
"@pushrocks/qenv": "^4.0.4",
"@pushrocks/tapbundle": "^3.0.13",
"@types/node": "^12.7.4"
},
"dependencies": {
"@pushrocks/smartrequest": "^1.0.6"
}
"@pushrocks/smartrequest": "^1.1.23"
},
"files": [
"ts/*",
"ts_web/*",
"dist/*",
"dist_web/*",
"assets/*",
"cli.js",
"npmextra.json",
"readme.md"
]
}

View File

@ -1,2 +1,2 @@
vars:
required:
- SLACK_TOKEN

View File

@ -1,26 +1,20 @@
# slackme
# @mojoio/slack
slack api abstraction for the mojo.io ecosystem
API abstraction for mojoio
## Availabililty
[![npm](https://mojoio.gitlab.io/assets/repo-button-npm.svg)](https://www.npmjs.com/package/slackme)
[![git](https://mojoio.gitlab.io/assets/repo-button-git.svg)](https://GitLab.com/mojoio/slackme)
[![git](https://mojoio.gitlab.io/assets/repo-button-mirror.svg)](https://github.com/mojoio/slackme)
[![docs](https://mojoio.gitlab.io/assets/repo-button-docs.svg)](https://mojoio.gitlab.io/slackme/)
## Availabililty and Links
* [npmjs.org (npm package)](https://www.npmjs.com/package/@mojoio/slack)
* [gitlab.com (source)](https://gitlab.com/mojoio/slack)
* [github.com (source mirror)](https://github.com/mojoio/slack)
* [docs (typedoc)](https://mojoio.gitlab.io/slack/)
## Status for master
[![build status](https://GitLab.com/mojoio/slackme/badges/master/build.svg)](https://GitLab.com/mojoio/slackme/commits/master)
[![coverage report](https://GitLab.com/mojoio/slackme/badges/master/coverage.svg)](https://GitLab.com/mojoio/slackme/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/slackme.svg)](https://www.npmjs.com/package/slackme)
[![Dependency Status](https://david-dm.org/mojoio/slackme.svg)](https://david-dm.org/mojoio/slackme)
[![bitHound Dependencies](https://www.bithound.io/github/mojoio/slackme/badges/dependencies.svg)](https://www.bithound.io/github/mojoio/slackme/master/dependencies/npm)
[![bitHound Code](https://www.bithound.io/github/mojoio/slackme/badges/code.svg)](https://www.bithound.io/github/mojoio/slackme)
[![Known Vulnerabilities](https://snyk.io/test/npm/slackme/badge.svg)](https://snyk.io/test/npm/slackme)
[![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)](https://standardjs.com/)
[![build status](https://gitlab.com/mojoio/slack/badges/master/build.svg)](https://gitlab.com/mojoio/slack/commits/master)
[![coverage report](https://gitlab.com/mojoio/slack/badges/master/coverage.svg)](https://gitlab.com/mojoio/slack/commits/master)
[![npm downloads per month](https://img.shields.io/npm/dm/@mojoio/slack.svg)](https://www.npmjs.com/package/@mojoio/slack)
[![Known Vulnerabilities](https://snyk.io/test/npm/@mojoio/slack/badge.svg)](https://snyk.io/test/npm/@mojoio/slack)
[![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
@ -104,9 +98,9 @@ mySlackMessage.title = 'another Title'
mySlackMessage.sendToRoom('anotherroom')
```
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)
> | By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy.html)
[![repo-footer](https://mojoio.gitlab.io/assets/repo-footer.svg)](https://mojo.io)
[![repo-footer](https://mojoio.gitlab.io/assets/repo-footer.svg)](https://maintainedby.lossless.com)

View File

@ -9,34 +9,54 @@ let testSlackme: slackme.Slackme;
let testSlackMessage: slackme.SlackMessage;
tap.test('should create a valid slackme instance', async () => {
testSlackme = new slackme.Slackme(process.env.SLACK_TOKEN);
testSlackme = new slackme.Slackme(testQenv.getEnvVarOnDemand('SLACK_TOKEN'));
});
tap.test('should send a message to Slack', async () => {
testSlackMessage = new slackme.SlackMessage(
{
author_name: 'GitLab CI',
author_link: 'https://gitlab.com/',
pretext: '*Good News*: Build successfull!',
color: '#3cb371',
fields: [
{
title: 'Branch',
value: 'Lossless Cloud',
short: true
},
{
title: 'Product ID',
value: 'pushrocks',
short: true
}
],
ts: new Date().getTime() / 1000
},
testSlackme
);
testSlackme.sendMessage(testSlackMessage.messageOptions, 'random');
testSlackMessage.sendToRoom('random');
testSlackMessage = new slackme.SlackMessage({
author_name: 'GitLab CI',
author_link: 'https://gitlab.com/',
pretext: '*Good News*: Build successfull!',
color: '#3cb371',
fields: [
{
title: 'Branch',
value: 'Lossless Cloud',
short: true
},
{
title: 'Product ID',
value: 'pushrocks',
short: true
}
],
ts: new Date().getTime() / 1000
});
await testSlackme.sendMessage(testSlackMessage.messageOptions, 'random');
await expect(testSlackMessage.sendToRoom('random')).to.eventually.be.rejected;
});
tap.test('should send a message to Slack by directly calling the message', async () => {
testSlackMessage = new slackme.SlackMessage({
author_name: 'GitLab CI',
author_link: 'https://gitlab.com/',
pretext: '*Good News*: Build successfull!',
color: '#3cb371',
fields: [
{
title: 'Branch',
value: 'Lossless Cloud',
short: true
},
{
title: 'Product ID',
value: 'pushrocks',
short: true
}
],
ts: new Date().getTime() / 1000
}, testSlackme);
await testSlackMessage.sendToRoom('random');
});
tap.start();

View File

@ -8,8 +8,8 @@ export class Slackme {
this.postRoute = postRouteArg;
}
sendMessage(messageOptionsArg: IMessageOptions, channelArg: string = 'general') {
plugins.smartrequest.postJson(`${this.baseUrl}${this.postRoute}`, {
async sendMessage(messageOptionsArg: IMessageOptions, channelArg: string = 'general') {
await plugins.smartrequest.postJson(`${this.baseUrl}${this.postRoute}`, {
requestBody: {
channel: channelArg,
attachments: [messageOptionsArg]

View File

@ -64,9 +64,11 @@ export class SlackMessage {
}
this.messageOptions = messageOptionsArg;
}
sendToRoom(roomNameArg: string) {
async sendToRoom(roomNameArg: string) {
if (this.slackmeRef) {
this.slackmeRef.sendMessage(this.messageOptions, roomNameArg);
await this.slackmeRef.sendMessage(this.messageOptions, roomNameArg);
} else {
throw new Error('you need to set a slackRef before sending the message!');
}
}
}

View File

@ -1,3 +1,4 @@
// pushrocks scope
import * as smartrequest from '@pushrocks/smartrequest';
export { smartrequest };

View File

@ -1,3 +1,17 @@
{
"extends": "tslint-config-standard"
"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"
}