Added CI and unit test infrastructure; updated packages.
This commit is contained in:
parent
517e20ddbb
commit
2c631ca8bd
10 changed files with 2483 additions and 314 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -7,3 +7,5 @@ work
|
||||||
tmp
|
tmp
|
||||||
docs
|
docs
|
||||||
.env
|
.env
|
||||||
|
.coveralls.yml
|
||||||
|
coverage
|
|
@ -3,4 +3,6 @@ guaribas.sqlite
|
||||||
guaribas.log
|
guaribas.log
|
||||||
work
|
work
|
||||||
tmp
|
tmp
|
||||||
.env
|
.env
|
||||||
|
.coveralls.yml
|
||||||
|
coverage
|
30
.nycrc
Normal file
30
.nycrc
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
{
|
||||||
|
"check-coverage": true,
|
||||||
|
"statements": 0,
|
||||||
|
"lines": 0,
|
||||||
|
"functions": 0,
|
||||||
|
"branches": 0,
|
||||||
|
"watermarks": {
|
||||||
|
"statements": [0, 0],
|
||||||
|
"lines": [0, 0],
|
||||||
|
"functions": [0, 0],
|
||||||
|
"branches": [0, 0]
|
||||||
|
},
|
||||||
|
"cache": true,
|
||||||
|
"extension": [
|
||||||
|
".ts"
|
||||||
|
],
|
||||||
|
"include": [
|
||||||
|
"packages/**"
|
||||||
|
],
|
||||||
|
"exclude": [
|
||||||
|
"**/node_modules/**/*",
|
||||||
|
"**/tests/**/*",
|
||||||
|
"**/default.gbui/**/*",
|
||||||
|
"**/line.gbui/**/*"
|
||||||
|
],
|
||||||
|
"reporter": [
|
||||||
|
"html"
|
||||||
|
],
|
||||||
|
"all": true
|
||||||
|
}
|
46
.travis.yaml
46
.travis.yaml
|
@ -1,30 +1,22 @@
|
||||||
language: node_js
|
language: node_js
|
||||||
|
|
||||||
node_js:
|
node_js:
|
||||||
- 'node'
|
- lts/*
|
||||||
- '10'
|
notifications:
|
||||||
- '6'
|
email: false
|
||||||
|
before_install:
|
||||||
sudo: false
|
- npm install --global nyc mocha typescript
|
||||||
|
|
||||||
env:
|
|
||||||
- workerCount=3 timeout=600000
|
|
||||||
|
|
||||||
matrix:
|
|
||||||
fast_finish: true
|
|
||||||
|
|
||||||
branches:
|
|
||||||
only:
|
|
||||||
- master
|
|
||||||
|
|
||||||
install:
|
install:
|
||||||
- npm uninstall typescript --no-save
|
- npm run update-versions
|
||||||
- npm uninstall tslint --no-save
|
script:
|
||||||
- npm install
|
- npm run test:travis
|
||||||
|
- npm run tslint
|
||||||
cache:
|
after_success:
|
||||||
directories:
|
- echo TRAVIS_EVENT_TYPE = $TRAVIS_EVENT_TYPE
|
||||||
- node_modules
|
- test $TRAVIS_EVENT_TYPE = "cron"
|
||||||
|
&& echo Begin deploy
|
||||||
git:
|
# && npm publish BotServer --registry=
|
||||||
depth: 1
|
&& echo End deploy
|
||||||
|
|
||||||
|
env:
|
||||||
|
global:
|
||||||
|
- Version=4.2.0-preview.${TRAVIS_BUILD_NUMBER}
|
2520
package-lock.json
generated
2520
package-lock.json
generated
File diff suppressed because it is too large
Load diff
95
package.json
95
package.json
|
@ -23,11 +23,13 @@
|
||||||
"startIde": "npm-run-all clean --parallel watch:build watch:server --print-label",
|
"startIde": "npm-run-all clean --parallel watch:build watch:server --print-label",
|
||||||
"watch:build": "tsc --watch",
|
"watch:build": "tsc --watch",
|
||||||
"watch:server": "nodemon './dist/index.js' --watch './dist'",
|
"watch:server": "nodemon './dist/index.js' --watch './dist'",
|
||||||
"test": "mocha -r ts-node/register src/**/*.test.ts",
|
"build-docs": "typedoc --options typedoc.json src/",
|
||||||
"build-docs": "typedoc --options typedoc.json src/"
|
"tslint": "tslint ./packages/*/src/**/*.ts -t verbose",
|
||||||
|
"test": "nyc --reporter=html --reporter=text mocha -r ts-node/register packages/**/*.test.ts ",
|
||||||
|
"coveralls": "npm run test && nyc report --reporter=text-lcov | coveralls"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "=8.11.1"
|
"node": "=10.13.0"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@microsoft/microsoft-graph-client": "1.3.0",
|
"@microsoft/microsoft-graph-client": "1.3.0",
|
||||||
|
@ -39,28 +41,28 @@
|
||||||
"adal-node": "0.1.28",
|
"adal-node": "0.1.28",
|
||||||
"async": "2.6.1",
|
"async": "2.6.1",
|
||||||
"async-promises": "0.2.1",
|
"async-promises": "0.2.1",
|
||||||
"azure-arm-cognitiveservices": "2.2.0",
|
"azure-arm-cognitiveservices": "2.4.0",
|
||||||
"azure-arm-resource": "7.0.1",
|
"azure-arm-resource": "7.1.0",
|
||||||
"azure-arm-search": "^1.2.0-preview",
|
"azure-arm-search": "^1.3.0-preview",
|
||||||
"azure-arm-sql": "5.3.0",
|
"azure-arm-sql": "5.6.0",
|
||||||
"azure-arm-website": "5.4.0",
|
"azure-arm-website": "5.6.0",
|
||||||
"body-parser": "1.18.3",
|
"body-parser": "1.18.3",
|
||||||
"botbuilder": "^4.1.3",
|
"botbuilder": "^4.1.5",
|
||||||
"botbuilder-ai": "^4.1.3",
|
"botbuilder-ai": "^4.1.5",
|
||||||
"botbuilder-azure": "^4.1.3",
|
"botbuilder-azure": "^4.1.5",
|
||||||
"botbuilder-choices": "^4.0.0-preview1.2",
|
"botbuilder-choices": "^4.0.0-preview1.2",
|
||||||
"botbuilder-dialogs": "^4.1.3",
|
"botbuilder-dialogs": "^4.1.5",
|
||||||
"botbuilder-prompts": "^4.0.0-preview1.2",
|
"botbuilder-prompts": "^4.0.0-preview1.2",
|
||||||
"botlib": "0.1.6",
|
"botlib": "0.1.6",
|
||||||
"chai": "4.2.0",
|
"chai": "4.2.0",
|
||||||
"child_process": "^1.0.2",
|
"child_process": "^1.0.2",
|
||||||
"chokidar": "2.0.4",
|
"chokidar": "2.0.4",
|
||||||
"cli-spinner": "^0.2.8",
|
"cli-spinner": "^0.2.8",
|
||||||
"csv-parse": "3.1.3",
|
"csv-parse": "3.2.0",
|
||||||
"dotenv-extended": "2.3.0",
|
"dotenv-extended": "2.3.0",
|
||||||
"express": "4.16.4",
|
"express": "4.16.4",
|
||||||
"express-promise-router": "3.0.3",
|
"express-promise-router": "3.0.3",
|
||||||
"fs-extra": "7.0.0",
|
"fs-extra": "7.0.1",
|
||||||
"fs-walk": "0.0.2",
|
"fs-walk": "0.0.2",
|
||||||
"ip": "^1.1.5",
|
"ip": "^1.1.5",
|
||||||
"localize": "0.4.7",
|
"localize": "0.4.7",
|
||||||
|
@ -71,6 +73,7 @@
|
||||||
"ms-rest-azure": "2.5.9",
|
"ms-rest-azure": "2.5.9",
|
||||||
"nexmo": "2.4.0",
|
"nexmo": "2.4.0",
|
||||||
"ngrok": "^3.1.0",
|
"ngrok": "^3.1.0",
|
||||||
|
"nyc": "^13.1.0",
|
||||||
"opn": "^5.4.0",
|
"opn": "^5.4.0",
|
||||||
"pragmatismo-io-framework": "1.0.18",
|
"pragmatismo-io-framework": "1.0.18",
|
||||||
"process-exists": "^3.1.0",
|
"process-exists": "^3.1.0",
|
||||||
|
@ -78,16 +81,18 @@
|
||||||
"reflect-metadata": "0.1.12",
|
"reflect-metadata": "0.1.12",
|
||||||
"request-promise-native": "1.0.5",
|
"request-promise-native": "1.0.5",
|
||||||
"scanf": "^1.0.2",
|
"scanf": "^1.0.2",
|
||||||
"sequelize": "4.41.0",
|
"sequelize": "4.41.1",
|
||||||
"sequelize-typescript": "0.6.6",
|
"sequelize-typescript": "0.6.6",
|
||||||
"simple-git": "^1.106.0",
|
"simple-git": "^1.107.0",
|
||||||
"sqlite3": "4.0.3",
|
"sqlite3": "4.0.4",
|
||||||
"strict-password-generator": "^1.1.1",
|
"strict-password-generator": "^1.1.1",
|
||||||
"swagger-client": "3.8.21",
|
"swagger-client": "3.8.22",
|
||||||
"tedious": "3.0.1",
|
"tedious": "3.0.1",
|
||||||
"ts-node": "7.0.1",
|
"ts-node": "7.0.1",
|
||||||
"tslint": "^5.11.0",
|
"tslint": "^5.11.0",
|
||||||
"typedoc": "0.13.0",
|
"typedoc": "0.13.0",
|
||||||
|
"typedoc-plugin-external-module-name": "^1.1.3",
|
||||||
|
"typedoc-plugin-markdown": "^1.1.18",
|
||||||
"typescript": "3.1.6",
|
"typescript": "3.1.6",
|
||||||
"url-join": "4.0.0",
|
"url-join": "4.0.0",
|
||||||
"wait-until": "0.0.2",
|
"wait-until": "0.0.2",
|
||||||
|
@ -95,6 +100,58 @@
|
||||||
"winston": "3.1.0"
|
"winston": "3.1.0"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"shx": "^0.3.2"
|
"@types/mocha": "^2.2.47",
|
||||||
|
"chai": "^4.2.0",
|
||||||
|
"coveralls": "^3.0.2",
|
||||||
|
"mocha": "^5.2.0",
|
||||||
|
"shx": "^0.3.2",
|
||||||
|
"ts-loader": "^5.3.0",
|
||||||
|
"tslint": "^5.11.0",
|
||||||
|
"tslint-microsoft-contrib": "^5.2.1"
|
||||||
|
},
|
||||||
|
"eslintConfig": {
|
||||||
|
"env": {
|
||||||
|
"node": true,
|
||||||
|
"es6": true,
|
||||||
|
"mocha": true
|
||||||
|
},
|
||||||
|
"extends": "eslint:recommended",
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2017
|
||||||
|
},
|
||||||
|
"rules": {
|
||||||
|
"indent": "off",
|
||||||
|
"linebreak-style": [
|
||||||
|
"warn",
|
||||||
|
"unix"
|
||||||
|
],
|
||||||
|
"no-unused-vars": [
|
||||||
|
"warn"
|
||||||
|
],
|
||||||
|
"no-undef": [
|
||||||
|
"warn"
|
||||||
|
],
|
||||||
|
"no-console": [
|
||||||
|
"warn"
|
||||||
|
],
|
||||||
|
"no-case-declarations": [
|
||||||
|
"warn"
|
||||||
|
],
|
||||||
|
"no-extra-semi": [
|
||||||
|
"warn"
|
||||||
|
],
|
||||||
|
"no-unreachable": [
|
||||||
|
"warn"
|
||||||
|
],
|
||||||
|
"no-redeclare": [
|
||||||
|
"warn"
|
||||||
|
],
|
||||||
|
"no-useless-escape": [
|
||||||
|
"warn"
|
||||||
|
],
|
||||||
|
"no-constant-condition": [
|
||||||
|
"warn"
|
||||||
|
]
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,6 +30,10 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @fileoverview General Bots server core.
|
||||||
|
*/
|
||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const logger = require("../../../src/logger");
|
const logger = require("../../../src/logger");
|
||||||
|
|
14
packages/core.gbapp/tests/core.test.ts
Normal file
14
packages/core.gbapp/tests/core.test.ts
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
|
||||||
|
import { expect } from 'chai'
|
||||||
|
import 'mocha'
|
||||||
|
import {GBImporter} from '../services/GBImporter'
|
||||||
|
|
||||||
|
describe('Hello function', () => {
|
||||||
|
|
||||||
|
it('should return empty test', () => {
|
||||||
|
let service = new GBImporter(null);
|
||||||
|
//service.importIfNotExistsBotPackage(null, null);
|
||||||
|
const result = 0;
|
||||||
|
expect(result).to.equal(0);
|
||||||
|
});
|
||||||
|
});
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
/*****************************************************************************\
|
/*****************************************************************************\
|
||||||
| ( )_ _ |
|
| ( )_ _ |
|
||||||
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
|
||||||
|
@ -9,7 +10,7 @@
|
||||||
| |
|
| |
|
||||||
| General Bots Copyright (c) Pragmatismo.io. All rights reserved. |
|
| General Bots Copyright (c) Pragmatismo.io. All rights reserved. |
|
||||||
| Licensed under the AGPL-3.0. |
|
| Licensed under the AGPL-3.0. |
|
||||||
| |
|
| |
|
||||||
| According to our dual licensing model, this program can be used either |
|
| According to our dual licensing model, this program can be used either |
|
||||||
| under the terms of the GNU Affero General Public License, version 3, |
|
| under the terms of the GNU Affero General Public License, version 3, |
|
||||||
| or under a proprietary license. |
|
| or under a proprietary license. |
|
||||||
|
@ -30,18 +31,22 @@
|
||||||
| |
|
| |
|
||||||
\*****************************************************************************/
|
\*****************************************************************************/
|
||||||
|
|
||||||
"use strict";
|
/**
|
||||||
|
* @fileoverview Main dialog for kb.gbapp
|
||||||
|
*/
|
||||||
|
|
||||||
const UrlJoin = require("url-join");
|
'use strict';
|
||||||
|
|
||||||
import { BotAdapter, CardFactory, MessageFactory } from "botbuilder";
|
const UrlJoin = require('url-join');
|
||||||
import { IGBDialog } from "botlib";
|
|
||||||
import { GBMinInstance } from "botlib";
|
import { BotAdapter, CardFactory, MessageFactory } from 'botbuilder';
|
||||||
import { GuaribasSubject } from "../models";
|
import { WaterfallDialog } from 'botbuilder-dialogs';
|
||||||
import { KBService } from "../services/KBService";
|
import { IGBDialog } from 'botlib';
|
||||||
import { Messages } from "../strings";
|
import { GBMinInstance } from 'botlib';
|
||||||
import { AzureText } from "pragmatismo-io-framework";
|
import { AzureText } from 'pragmatismo-io-framework';
|
||||||
import { WaterfallDialog } from "botbuilder-dialogs";
|
import { GuaribasSubject } from '../models';
|
||||||
|
import { KBService } from '../services/KBService';
|
||||||
|
import { Messages } from '../strings';
|
||||||
|
|
||||||
export class MenuDialog extends IGBDialog {
|
export class MenuDialog extends IGBDialog {
|
||||||
/**
|
/**
|
||||||
|
@ -50,22 +55,22 @@ export class MenuDialog extends IGBDialog {
|
||||||
* @param bot The bot adapter.
|
* @param bot The bot adapter.
|
||||||
* @param min The minimal bot instance data.
|
* @param min The minimal bot instance data.
|
||||||
*/
|
*/
|
||||||
static setup(bot: BotAdapter, min: GBMinInstance) {
|
public static setup(bot: BotAdapter, min: GBMinInstance) {
|
||||||
var service = new KBService(min.core.sequelize);
|
const service = new KBService(min.core.sequelize);
|
||||||
|
|
||||||
min.dialogs.add(new WaterfallDialog("/menu", [
|
min.dialogs.add(new WaterfallDialog('/menu', [
|
||||||
async step => {
|
async step => {
|
||||||
const locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
var rootSubjectId = null;
|
let rootSubjectId = null;
|
||||||
|
|
||||||
if (step.options && step.options["data"]) {
|
if (step.options && step.options['data']) {
|
||||||
var subject = step.result.data;
|
const subject = step.result.data;
|
||||||
|
|
||||||
// If there is a shortcut specified as subject destination, go there.
|
// If there is a shortcut specified as subject destination, go there.
|
||||||
|
|
||||||
if (subject.to) {
|
if (subject.to) {
|
||||||
let dialog = subject.to.split(":")[1];
|
const dialog = subject.to.split(':')[1];
|
||||||
await step.replaceDialog("/" + dialog);
|
await step.replaceDialog('/' + dialog);
|
||||||
await step.endDialog();
|
await step.endDialog();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -79,12 +84,12 @@ export class MenuDialog extends IGBDialog {
|
||||||
// Whenever a subject is selected, shows a faq about it.
|
// Whenever a subject is selected, shows a faq about it.
|
||||||
|
|
||||||
if (user.subjects.length > 0) {
|
if (user.subjects.length > 0) {
|
||||||
let data = await service.getFaqBySubjectArray(
|
const data = await service.getFaqBySubjectArray(
|
||||||
"menu",
|
'menu',
|
||||||
user.subjects
|
user.subjects
|
||||||
);
|
);
|
||||||
await min.conversationalService.sendEvent(step, "play", {
|
await min.conversationalService.sendEvent(step, 'play', {
|
||||||
playerType: "bullet",
|
playerType: 'bullet',
|
||||||
data: data.slice(0, 10)
|
data: data.slice(0, 10)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -96,27 +101,28 @@ export class MenuDialog extends IGBDialog {
|
||||||
user.isAsking = false;
|
user.isAsking = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
const msg = MessageFactory.text("");
|
const msg = MessageFactory.text('');
|
||||||
var attachments = [];
|
const attachments = [];
|
||||||
|
|
||||||
let data = await service.getSubjectItems(
|
const data = await service.getSubjectItems(
|
||||||
min.instance.instanceId,
|
min.instance.instanceId,
|
||||||
rootSubjectId
|
rootSubjectId
|
||||||
);
|
);
|
||||||
|
|
||||||
msg.attachmentLayout = "carousel";
|
msg.attachmentLayout = 'carousel';
|
||||||
|
|
||||||
data.forEach(function(item: GuaribasSubject) {
|
data.forEach(function(item: GuaribasSubject) {
|
||||||
var subject = item;
|
const subject = item;
|
||||||
var card = CardFactory.heroCard(
|
const card = CardFactory.heroCard(
|
||||||
subject.title,
|
subject.title,
|
||||||
subject.description,
|
subject.description,
|
||||||
CardFactory.images([
|
CardFactory.images([
|
||||||
UrlJoin("/kb", min.instance.kb, "subjects", "subject.png")
|
UrlJoin('/kb', min.instance.kb, 'subjects', 'subject.png')
|
||||||
]),
|
]),
|
||||||
CardFactory.actions([
|
CardFactory.actions([
|
||||||
{
|
{
|
||||||
type: "postBack",
|
channelData: null,
|
||||||
|
type: 'postBack',
|
||||||
title: Messages[locale].menu_select,
|
title: Messages[locale].menu_select,
|
||||||
value: JSON.stringify({
|
value: JSON.stringify({
|
||||||
title: subject.title,
|
title: subject.title,
|
||||||
|
@ -132,7 +138,7 @@ export class MenuDialog extends IGBDialog {
|
||||||
attachments.push(card);
|
attachments.push(card);
|
||||||
});
|
});
|
||||||
|
|
||||||
if (attachments.length == 0) {
|
if (attachments.length === 0) {
|
||||||
const user = await min.userProfile.get(context, {});
|
const user = await min.userProfile.get(context, {});
|
||||||
|
|
||||||
if (user.subjects && user.subjects.length > 0) {
|
if (user.subjects && user.subjects.length > 0) {
|
||||||
|
@ -143,7 +149,7 @@ export class MenuDialog extends IGBDialog {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
await step.replaceDialog("/ask", {});
|
await step.replaceDialog('/ask', {});
|
||||||
} else {
|
} else {
|
||||||
msg.attachments = attachments;
|
msg.attachments = attachments;
|
||||||
await step.context.sendActivity(msg);
|
await step.context.sendActivity(msg);
|
||||||
|
@ -154,12 +160,12 @@ export class MenuDialog extends IGBDialog {
|
||||||
return await step.next();
|
return await step.next();
|
||||||
},
|
},
|
||||||
async step => {
|
async step => {
|
||||||
var text = step.result;
|
const text = step.result;
|
||||||
const locale = step.context.activity.locale;
|
const locale = step.context.activity.locale;
|
||||||
if (AzureText.isIntentNo(locale, text)) {
|
if (AzureText.isIntentNo(locale, text)) {
|
||||||
await step.replaceDialog("/feedback");
|
await step.replaceDialog('/feedback');
|
||||||
} else {
|
} else {
|
||||||
await step.replaceDialog("/ask");
|
await step.replaceDialog('/ask');
|
||||||
}
|
}
|
||||||
return await step.next();
|
return await step.next();
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,6 +32,6 @@
|
||||||
"no-parameter-reassignment":false,
|
"no-parameter-reassignment":false,
|
||||||
"export-name":false,
|
"export-name":false,
|
||||||
"no-relative-imports": false,
|
"no-relative-imports": false,
|
||||||
"max-line-length": [true,{"limit":140,"ignore-pattern":"^\\s+\\*"}]
|
"max-line-length": [true,{"limit":80,"ignore-pattern":"^\\s+\\*"}]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue