fix(core): update
This commit is contained in:
parent
55e75766b7
commit
eeb1a99884
19
.gitignore
vendored
19
.gitignore
vendored
@ -1,5 +1,22 @@
|
|||||||
.nogit/
|
.nogit/
|
||||||
node_modules/
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
pages/
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_web/
|
||||||
|
dist_serve/
|
||||||
|
dist_ts_web/
|
||||||
|
|
||||||
|
# custom
|
@ -1,5 +1,5 @@
|
|||||||
# gitzone standard
|
# gitzone ci_default
|
||||||
image: hosttoday/ht-docker-node:npmci
|
image: registry.gitlab.com/hosttoday/ht-docker-node:npmci
|
||||||
|
|
||||||
cache:
|
cache:
|
||||||
paths:
|
paths:
|
||||||
@ -26,6 +26,7 @@ mirror:
|
|||||||
snyk:
|
snyk:
|
||||||
stage: security
|
stage: security
|
||||||
script:
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
- npmci command npm install -g snyk
|
- npmci command npm install -g snyk
|
||||||
- npmci command npm install --ignore-scripts
|
- npmci command npm install --ignore-scripts
|
||||||
- npmci command snyk test
|
- npmci command snyk test
|
||||||
@ -36,21 +37,11 @@ snyk:
|
|||||||
# ====================
|
# ====================
|
||||||
# test stage
|
# 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:
|
testLTS:
|
||||||
stage: test
|
stage: test
|
||||||
script:
|
script:
|
||||||
|
- npmci npm prepare
|
||||||
- npmci node install lts
|
- npmci node install lts
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci npm test
|
- npmci npm test
|
||||||
@ -58,22 +49,11 @@ testLTS:
|
|||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
release:
|
||||||
stage: release
|
stage: release
|
||||||
script:
|
script:
|
||||||
- npmci node install stable
|
- npmci node install lts
|
||||||
- npmci npm publish
|
- npmci npm publish
|
||||||
only:
|
only:
|
||||||
- tags
|
- tags
|
||||||
@ -86,19 +66,11 @@ release:
|
|||||||
# ====================
|
# ====================
|
||||||
codequality:
|
codequality:
|
||||||
stage: metadata
|
stage: metadata
|
||||||
image: docker:stable
|
|
||||||
allow_failure: true
|
allow_failure: true
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
script:
|
script:
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
- npmci command npm install -g tslint typescript
|
||||||
- docker run
|
- npmci npm install
|
||||||
--env SOURCE_CODE="$PWD"
|
- npmci command "tslint -c tslint.json ./ts/**/*.ts"
|
||||||
--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]
|
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- priv
|
- priv
|
||||||
@ -117,9 +89,10 @@ pages:
|
|||||||
image: hosttoday/ht-docker-node:npmci
|
image: hosttoday/ht-docker-node:npmci
|
||||||
stage: metadata
|
stage: metadata
|
||||||
script:
|
script:
|
||||||
- npmci command npm install -g typedoc typescript
|
- npmci command npm install -g @gitzone/tsdoc
|
||||||
|
- npmci npm prepare
|
||||||
- npmci npm install
|
- npmci npm install
|
||||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
- npmci command tsdoc
|
||||||
tags:
|
tags:
|
||||||
- docker
|
- docker
|
||||||
- notpriv
|
- notpriv
|
||||||
@ -130,13 +103,3 @@ pages:
|
|||||||
paths:
|
paths:
|
||||||
- public
|
- public
|
||||||
allow_failure: true
|
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
|
|
||||||
|
@ -2,5 +2,15 @@
|
|||||||
"npmci": {
|
"npmci": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"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
1188
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
28
package.json
28
package.json
@ -2,7 +2,7 @@
|
|||||||
"name": "@mojoio/slack",
|
"name": "@mojoio/slack",
|
||||||
"version": "2.0.6",
|
"version": "2.0.6",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "API abstraction for mojoio",
|
"description": "slack api abstraction for the mojo.io ecosystem",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"typings": "dist/index.d.ts",
|
"typings": "dist/index.d.ts",
|
||||||
"author": "Lossless GmbH",
|
"author": "Lossless GmbH",
|
||||||
@ -12,14 +12,24 @@
|
|||||||
"build": "tsbuild"
|
"build": "tsbuild"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.0.22",
|
"@gitzone/tsbuild": "^2.1.17",
|
||||||
"@gitzone/tsrun": "^1.1.12",
|
"@gitzone/tsrun": "^1.2.8",
|
||||||
"@gitzone/tstest": "^1.0.15",
|
"@gitzone/tstest": "^1.0.24",
|
||||||
"@pushrocks/qenv": "^2.0.2",
|
"@pushrocks/qenv": "^4.0.4",
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
"@pushrocks/tapbundle": "^3.0.13",
|
||||||
"@types/node": "^10.11.4"
|
"@types/node": "^12.7.4"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"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"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
40
readme.md
40
readme.md
@ -1,26 +1,20 @@
|
|||||||
# slackme
|
# @mojoio/slack
|
||||||
|
slack api abstraction for the mojo.io ecosystem
|
||||||
|
|
||||||
API abstraction for mojoio
|
## Availabililty and Links
|
||||||
|
* [npmjs.org (npm package)](https://www.npmjs.com/package/@mojoio/slack)
|
||||||
## Availabililty
|
* [gitlab.com (source)](https://gitlab.com/mojoio/slack)
|
||||||
|
* [github.com (source mirror)](https://github.com/mojoio/slack)
|
||||||
[](https://www.npmjs.com/package/slackme)
|
* [docs (typedoc)](https://mojoio.gitlab.io/slack/)
|
||||||
[](https://GitLab.com/mojoio/slackme)
|
|
||||||
[](https://github.com/mojoio/slackme)
|
|
||||||
[](https://mojoio.gitlab.io/slackme/)
|
|
||||||
|
|
||||||
## Status for master
|
## Status for master
|
||||||
|
[](https://gitlab.com/mojoio/slack/commits/master)
|
||||||
[](https://GitLab.com/mojoio/slackme/commits/master)
|
[](https://gitlab.com/mojoio/slack/commits/master)
|
||||||
[](https://GitLab.com/mojoio/slackme/commits/master)
|
[](https://www.npmjs.com/package/@mojoio/slack)
|
||||||
[](https://www.npmjs.com/package/slackme)
|
[](https://snyk.io/test/npm/@mojoio/slack)
|
||||||
[](https://david-dm.org/mojoio/slackme)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](https://www.bithound.io/github/mojoio/slackme/master/dependencies/npm)
|
[](https://nodejs.org/dist/latest-v10.x/docs/api/)
|
||||||
[](https://www.bithound.io/github/mojoio/slackme)
|
[](https://prettier.io/)
|
||||||
[](https://snyk.io/test/npm/slackme)
|
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](https://nodejs.org/dist/latest-v6.x/docs/api/)
|
|
||||||
[](https://standardjs.com/)
|
|
||||||
|
|
||||||
## Usage
|
## Usage
|
||||||
|
|
||||||
@ -104,9 +98,9 @@ mySlackMessage.title = 'another Title'
|
|||||||
mySlackMessage.sendToRoom('anotherroom')
|
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)
|
> 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)
|
||||||
|
|
||||||
[](https://mojo.io)
|
[](https://maintainedby.lossless.com)
|
||||||
|
70
test/test.ts
70
test/test.ts
@ -9,34 +9,54 @@ let testSlackme: slackme.Slackme;
|
|||||||
let testSlackMessage: slackme.SlackMessage;
|
let testSlackMessage: slackme.SlackMessage;
|
||||||
|
|
||||||
tap.test('should create a valid slackme instance', async () => {
|
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 () => {
|
tap.test('should send a message to Slack', async () => {
|
||||||
testSlackMessage = new slackme.SlackMessage(
|
testSlackMessage = new slackme.SlackMessage({
|
||||||
{
|
author_name: 'GitLab CI',
|
||||||
author_name: 'GitLab CI',
|
author_link: 'https://gitlab.com/',
|
||||||
author_link: 'https://gitlab.com/',
|
pretext: '*Good News*: Build successfull!',
|
||||||
pretext: '*Good News*: Build successfull!',
|
color: '#3cb371',
|
||||||
color: '#3cb371',
|
fields: [
|
||||||
fields: [
|
{
|
||||||
{
|
title: 'Branch',
|
||||||
title: 'Branch',
|
value: 'Lossless Cloud',
|
||||||
value: 'Lossless Cloud',
|
short: true
|
||||||
short: true
|
},
|
||||||
},
|
{
|
||||||
{
|
title: 'Product ID',
|
||||||
title: 'Product ID',
|
value: 'pushrocks',
|
||||||
value: 'pushrocks',
|
short: true
|
||||||
short: true
|
}
|
||||||
}
|
],
|
||||||
],
|
ts: new Date().getTime() / 1000
|
||||||
ts: new Date().getTime() / 1000
|
});
|
||||||
},
|
await testSlackme.sendMessage(testSlackMessage.messageOptions, 'random');
|
||||||
testSlackme
|
await expect(testSlackMessage.sendToRoom('random')).to.eventually.be.rejected;
|
||||||
);
|
});
|
||||||
testSlackme.sendMessage(testSlackMessage.messageOptions, 'random');
|
|
||||||
testSlackMessage.sendToRoom('random');
|
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();
|
tap.start();
|
||||||
|
@ -8,8 +8,8 @@ export class Slackme {
|
|||||||
this.postRoute = postRouteArg;
|
this.postRoute = postRouteArg;
|
||||||
}
|
}
|
||||||
|
|
||||||
sendMessage(messageOptionsArg: IMessageOptions, channelArg: string = 'general') {
|
async sendMessage(messageOptionsArg: IMessageOptions, channelArg: string = 'general') {
|
||||||
plugins.smartrequest.postJson(`${this.baseUrl}${this.postRoute}`, {
|
await plugins.smartrequest.postJson(`${this.baseUrl}${this.postRoute}`, {
|
||||||
requestBody: {
|
requestBody: {
|
||||||
channel: channelArg,
|
channel: channelArg,
|
||||||
attachments: [messageOptionsArg]
|
attachments: [messageOptionsArg]
|
||||||
|
@ -64,9 +64,11 @@ export class SlackMessage {
|
|||||||
}
|
}
|
||||||
this.messageOptions = messageOptionsArg;
|
this.messageOptions = messageOptionsArg;
|
||||||
}
|
}
|
||||||
sendToRoom(roomNameArg: string) {
|
async sendToRoom(roomNameArg: string) {
|
||||||
if (this.slackmeRef) {
|
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!');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,3 +1,4 @@
|
|||||||
|
// pushrocks scope
|
||||||
import * as smartrequest from '@pushrocks/smartrequest';
|
import * as smartrequest from '@pushrocks/smartrequest';
|
||||||
|
|
||||||
export { smartrequest };
|
export { smartrequest };
|
||||||
|
16
tslint.json
16
tslint.json
@ -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"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user