Added CI and unit test infrastructure; updated packages.

This commit is contained in:
Rodrigo Rodriguez (pragmatismo.io) 2018-11-11 17:31:17 -02:00
parent 517e20ddbb
commit 2c631ca8bd
10 changed files with 2483 additions and 314 deletions

2
.gitignore vendored
View file

@ -7,3 +7,5 @@ work
tmp
docs
.env
.coveralls.yml
coverage

View file

@ -4,3 +4,5 @@ guaribas.log
work
tmp
.env
.coveralls.yml
coverage

30
.nycrc Normal file
View 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
}

View file

@ -1,30 +1,22 @@
language: node_js
node_js:
- 'node'
- '10'
- '6'
sudo: false
- lts/*
notifications:
email: false
before_install:
- npm install --global nyc mocha typescript
install:
- npm run update-versions
script:
- npm run test:travis
- npm run tslint
after_success:
- echo TRAVIS_EVENT_TYPE = $TRAVIS_EVENT_TYPE
- test $TRAVIS_EVENT_TYPE = "cron"
&& echo Begin deploy
# && npm publish BotServer --registry=
&& echo End deploy
env:
- workerCount=3 timeout=600000
matrix:
fast_finish: true
branches:
only:
- master
install:
- npm uninstall typescript --no-save
- npm uninstall tslint --no-save
- npm install
cache:
directories:
- node_modules
git:
depth: 1
global:
- Version=4.2.0-preview.${TRAVIS_BUILD_NUMBER}

2518
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -23,11 +23,13 @@
"startIde": "npm-run-all clean --parallel watch:build watch:server --print-label",
"watch:build": "tsc --watch",
"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": {
"node": "=8.11.1"
"node": "=10.13.0"
},
"dependencies": {
"@microsoft/microsoft-graph-client": "1.3.0",
@ -39,28 +41,28 @@
"adal-node": "0.1.28",
"async": "2.6.1",
"async-promises": "0.2.1",
"azure-arm-cognitiveservices": "2.2.0",
"azure-arm-resource": "7.0.1",
"azure-arm-search": "^1.2.0-preview",
"azure-arm-sql": "5.3.0",
"azure-arm-website": "5.4.0",
"azure-arm-cognitiveservices": "2.4.0",
"azure-arm-resource": "7.1.0",
"azure-arm-search": "^1.3.0-preview",
"azure-arm-sql": "5.6.0",
"azure-arm-website": "5.6.0",
"body-parser": "1.18.3",
"botbuilder": "^4.1.3",
"botbuilder-ai": "^4.1.3",
"botbuilder-azure": "^4.1.3",
"botbuilder": "^4.1.5",
"botbuilder-ai": "^4.1.5",
"botbuilder-azure": "^4.1.5",
"botbuilder-choices": "^4.0.0-preview1.2",
"botbuilder-dialogs": "^4.1.3",
"botbuilder-dialogs": "^4.1.5",
"botbuilder-prompts": "^4.0.0-preview1.2",
"botlib": "0.1.6",
"chai": "4.2.0",
"child_process": "^1.0.2",
"chokidar": "2.0.4",
"cli-spinner": "^0.2.8",
"csv-parse": "3.1.3",
"csv-parse": "3.2.0",
"dotenv-extended": "2.3.0",
"express": "4.16.4",
"express-promise-router": "3.0.3",
"fs-extra": "7.0.0",
"fs-extra": "7.0.1",
"fs-walk": "0.0.2",
"ip": "^1.1.5",
"localize": "0.4.7",
@ -71,6 +73,7 @@
"ms-rest-azure": "2.5.9",
"nexmo": "2.4.0",
"ngrok": "^3.1.0",
"nyc": "^13.1.0",
"opn": "^5.4.0",
"pragmatismo-io-framework": "1.0.18",
"process-exists": "^3.1.0",
@ -78,16 +81,18 @@
"reflect-metadata": "0.1.12",
"request-promise-native": "1.0.5",
"scanf": "^1.0.2",
"sequelize": "4.41.0",
"sequelize": "4.41.1",
"sequelize-typescript": "0.6.6",
"simple-git": "^1.106.0",
"sqlite3": "4.0.3",
"simple-git": "^1.107.0",
"sqlite3": "4.0.4",
"strict-password-generator": "^1.1.1",
"swagger-client": "3.8.21",
"swagger-client": "3.8.22",
"tedious": "3.0.1",
"ts-node": "7.0.1",
"tslint": "^5.11.0",
"typedoc": "0.13.0",
"typedoc-plugin-external-module-name": "^1.1.3",
"typedoc-plugin-markdown": "^1.1.18",
"typescript": "3.1.6",
"url-join": "4.0.0",
"wait-until": "0.0.2",
@ -95,6 +100,58 @@
"winston": "3.1.0"
},
"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"
]
}
}
}

View file

@ -30,6 +30,10 @@
| |
\*****************************************************************************/
/**
* @fileoverview General Bots server core.
*/
"use strict";
const logger = require("../../../src/logger");

View 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);
});
});

View file

@ -1,3 +1,4 @@
/*****************************************************************************\
| ( )_ _ |
| _ _ _ __ _ _ __ ___ ___ _ _ | ,_)(_) ___ ___ _ |
@ -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";
import { IGBDialog } from "botlib";
import { GBMinInstance } from "botlib";
import { GuaribasSubject } from "../models";
import { KBService } from "../services/KBService";
import { Messages } from "../strings";
import { AzureText } from "pragmatismo-io-framework";
import { WaterfallDialog } from "botbuilder-dialogs";
const UrlJoin = require('url-join');
import { BotAdapter, CardFactory, MessageFactory } from 'botbuilder';
import { WaterfallDialog } from 'botbuilder-dialogs';
import { IGBDialog } from 'botlib';
import { GBMinInstance } from 'botlib';
import { AzureText } from 'pragmatismo-io-framework';
import { GuaribasSubject } from '../models';
import { KBService } from '../services/KBService';
import { Messages } from '../strings';
export class MenuDialog extends IGBDialog {
/**
@ -50,22 +55,22 @@ export class MenuDialog extends IGBDialog {
* @param bot The bot adapter.
* @param min The minimal bot instance data.
*/
static setup(bot: BotAdapter, min: GBMinInstance) {
var service = new KBService(min.core.sequelize);
public static setup(bot: BotAdapter, min: GBMinInstance) {
const service = new KBService(min.core.sequelize);
min.dialogs.add(new WaterfallDialog("/menu", [
min.dialogs.add(new WaterfallDialog('/menu', [
async step => {
const locale = step.context.activity.locale;
var rootSubjectId = null;
let rootSubjectId = null;
if (step.options && step.options["data"]) {
var subject = step.result.data;
if (step.options && step.options['data']) {
const subject = step.result.data;
// If there is a shortcut specified as subject destination, go there.
if (subject.to) {
let dialog = subject.to.split(":")[1];
await step.replaceDialog("/" + dialog);
const dialog = subject.to.split(':')[1];
await step.replaceDialog('/' + dialog);
await step.endDialog();
return;
}
@ -79,12 +84,12 @@ export class MenuDialog extends IGBDialog {
// Whenever a subject is selected, shows a faq about it.
if (user.subjects.length > 0) {
let data = await service.getFaqBySubjectArray(
"menu",
const data = await service.getFaqBySubjectArray(
'menu',
user.subjects
);
await min.conversationalService.sendEvent(step, "play", {
playerType: "bullet",
await min.conversationalService.sendEvent(step, 'play', {
playerType: 'bullet',
data: data.slice(0, 10)
});
}
@ -96,27 +101,28 @@ export class MenuDialog extends IGBDialog {
user.isAsking = false;
}
const msg = MessageFactory.text("");
var attachments = [];
const msg = MessageFactory.text('');
const attachments = [];
let data = await service.getSubjectItems(
const data = await service.getSubjectItems(
min.instance.instanceId,
rootSubjectId
);
msg.attachmentLayout = "carousel";
msg.attachmentLayout = 'carousel';
data.forEach(function(item: GuaribasSubject) {
var subject = item;
var card = CardFactory.heroCard(
const subject = item;
const card = CardFactory.heroCard(
subject.title,
subject.description,
CardFactory.images([
UrlJoin("/kb", min.instance.kb, "subjects", "subject.png")
UrlJoin('/kb', min.instance.kb, 'subjects', 'subject.png')
]),
CardFactory.actions([
{
type: "postBack",
channelData: null,
type: 'postBack',
title: Messages[locale].menu_select,
value: JSON.stringify({
title: subject.title,
@ -132,7 +138,7 @@ export class MenuDialog extends IGBDialog {
attachments.push(card);
});
if (attachments.length == 0) {
if (attachments.length === 0) {
const user = await min.userProfile.get(context, {});
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 {
msg.attachments = attachments;
await step.context.sendActivity(msg);
@ -154,12 +160,12 @@ export class MenuDialog extends IGBDialog {
return await step.next();
},
async step => {
var text = step.result;
const text = step.result;
const locale = step.context.activity.locale;
if (AzureText.isIntentNo(locale, text)) {
await step.replaceDialog("/feedback");
await step.replaceDialog('/feedback');
} else {
await step.replaceDialog("/ask");
await step.replaceDialog('/ask');
}
return await step.next();
}

View file

@ -32,6 +32,6 @@
"no-parameter-reassignment":false,
"export-name":false,
"no-relative-imports": false,
"max-line-length": [true,{"limit":140,"ignore-pattern":"^\\s+\\*"}]
"max-line-length": [true,{"limit":80,"ignore-pattern":"^\\s+\\*"}]
}
}