Skip to content

Commit

Permalink
Merge pull request #31 from kengz/convo-engine-and-style-fixes
Browse files Browse the repository at this point in the history
ESLint style fixes; convo engine
  • Loading branch information
kengz authored Dec 24, 2016
2 parents 961e51b + 7e9a1e4 commit 4e271ab
Show file tree
Hide file tree
Showing 41 changed files with 795 additions and 710 deletions.
35 changes: 0 additions & 35 deletions .codeclimate.yml

This file was deleted.

18 changes: 18 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"extends": "airbnb",
"plugins": [
"react",
"jsx-a11y",
"import"
],
"env": {
"node": true,
"es6": true,
"mocha": true
},
"rules": {
"semi": ["error", "never"],
"import/no-unresolved": 0,
"import/no-extraneous-dependencies": 0
}
}
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# AIVA [![GitHub version](https://badge.fury.io/gh/kengz%2Faiva.svg)](http://badge.fury.io/gh/kengz%2Faiva) [![CircleCI](https://circleci.com/gh/kengz/poly-socketio.svg?style=shield)](https://circleci.com/gh/kengz/poly-socketio) [![Code Climate](https://codeclimate.com/github/kengz/aiva/badges/gpa.svg)](https://codeclimate.com/github/kengz/aiva) [![Test Coverage](https://codeclimate.com/github/kengz/aiva/badges/coverage.svg)](https://codeclimate.com/github/kengz/aiva/coverage) [![Dependency Status](https://gemnasium.com/kengz/aiva.svg)](https://gemnasium.com/kengz/aiva) [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/hyperium/hyper/master/LICENSE) [![GitHub forks](https://img.shields.io/github/forks/kengz/aiva.svg?style=social&label=Fork)](https://github.com/kengz/aiva) [![GitHub stars](https://img.shields.io/github/stars/kengz/aiva.svg?style=social&label=Star)](https://github.com/kengz/aiva)
# AIVA [![GitHub version](https://badge.fury.io/gh/kengz%2Faiva.svg)](http://badge.fury.io/gh/kengz%2Faiva) [![CircleCI](https://circleci.com/gh/kengz/poly-socketio.svg?style=shield)](https://circleci.com/gh/kengz/poly-socketio) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/53459c1d07154b5e8d95d9f9922e5e7a)](https://www.codacy.com/app/kengzwl/aiva?utm_source=github.com&utm_medium=referral&utm_content=kengz/aiva&utm_campaign=Badge_Grade) [![Codacy Badge](https://api.codacy.com/project/badge/Coverage/53459c1d07154b5e8d95d9f9922e5e7a)](https://www.codacy.com/app/kengzwl/aiva?utm_source=github.com&utm_medium=referral&utm_content=kengz/aiva&utm_campaign=Badge_Coverage) [![Dependency Status](https://gemnasium.com/kengz/aiva.svg)](https://gemnasium.com/kengz/aiva) [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/hyperium/hyper/master/LICENSE) [![GitHub forks](https://img.shields.io/github/forks/kengz/aiva.svg?style=social&label=Fork)](https://github.com/kengz/aiva) [![GitHub stars](https://img.shields.io/github/stars/kengz/aiva.svg?style=social&label=Star)](https://github.com/kengz/aiva)

**AIVA** (A.I. Virtual Assistant): General-purpose virtual assistant for developers. [http://kengz.me/aiva/](http://kengz.me/aiva/)

Expand Down
4 changes: 1 addition & 3 deletions circle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ machine:
version: 3.5.1
node:
version: 6
environment:
CODECLIMATE_REPO_TOKEN: df0a1e703d4e417fb88724c9e1f7c4b49f53c9c17494d59cd182aa6cc2daccf8
services:
- mysql
- neo4j
Expand All @@ -27,7 +25,7 @@ test:
override:
- npm test
post:
- cat ./coverage/lcov.info | ./node_modules/codeclimate-test-reporter/bin/codeclimate.js
- cat ./coverage/lcov.info | ./node_modules/.bin/codacy-coverage

general:
branches:
Expand Down
21 changes: 10 additions & 11 deletions db/migrations/20161003021116-create-chatlog.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,34 @@
'use strict';
// to create: sequelize migration:create --name create-chatlog
// to run: sequelize db:migrate
// to revert: sequelize db:migrate:undo:all

module.exports = {
up: function(queryInterface, Sequelize) {
up(queryInterface, Sequelize) {
return queryInterface.createTable('Chatlogs', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
type: Sequelize.INTEGER,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
type: Sequelize.DATE,
},
adapter: Sequelize.STRING,
userid: Sequelize.STRING,
username: Sequelize.STRING,
room: Sequelize.STRING,
incoming: Sequelize.BOOLEAN,
method: Sequelize.STRING,
message: Sequelize.STRING
});
message: Sequelize.STRING,
})
},
down: function(queryInterface, Sequelize) {
return queryInterface.dropTable('Chatlogs');
}
};
down(queryInterface) {
return queryInterface.dropTable('Chatlogs')
},
}
31 changes: 15 additions & 16 deletions db/migrations/20161007155536-create-user.js
Original file line number Diff line number Diff line change
@@ -1,38 +1,37 @@
'use strict';
module.exports = {
up: function(queryInterface, Sequelize) {
up(queryInterface, Sequelize) {
return queryInterface.createTable('Users', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER
type: Sequelize.INTEGER,
},
adapter: {
allowNull: false,
type: Sequelize.STRING
type: Sequelize.STRING,
},
userid: {
allowNull: false,
type: Sequelize.STRING
type: Sequelize.STRING,
},
username: {
type: Sequelize.STRING
type: Sequelize.STRING,
},
profile: {
type: Sequelize.TEXT
envelope: {
type: Sequelize.TEXT,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE
}
});
type: Sequelize.DATE,
},
})
},
down(queryInterface) {
return queryInterface.dropTable('Users')
},
down: function(queryInterface, Sequelize) {
return queryInterface.dropTable('Users');
}
};
}
35 changes: 35 additions & 0 deletions db/migrations/20161219230220-create-cronjob.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module.exports = {
up(queryInterface, Sequelize) {
return queryInterface.createTable('Cronjobs', {
id: {
allowNull: false,
autoIncrement: true,
primaryKey: true,
type: Sequelize.INTEGER,
},
adapter: {
type: Sequelize.STRING,
},
userid: {
type: Sequelize.STRING,
},
pattern: {
type: Sequelize.STRING,
},
command: {
type: Sequelize.TEXT,
},
createdAt: {
allowNull: false,
type: Sequelize.DATE,
},
updatedAt: {
allowNull: false,
type: Sequelize.DATE,
},
})
},
down(queryInterface) {
return queryInterface.dropTable('Cronjobs')
},
}
23 changes: 11 additions & 12 deletions db/models/chatlog.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,22 @@
'use strict';
// create with:
// sequelize model:create --name Chatlog --attributes "adapter:string"

module.exports = function(sequelize, DataTypes) {
var Chatlog = sequelize.define('Chatlog', {
module.exports = function fn(sequelize, DataTypes) {
const Chatlog = sequelize.define('Chatlog', {
adapter: DataTypes.STRING,
userid: DataTypes.STRING,
username: DataTypes.STRING,
room: DataTypes.STRING,
incoming: DataTypes.BOOLEAN,
method: DataTypes.STRING,
message: DataTypes.TEXT
message: DataTypes.TEXT,
}, {
classMethods: {
associate: function(models) {
// associations can be defined here
// Chatlog.belongsTo(models.User)
}
}
});
return Chatlog;
};
// associate(models) {
// associations can be defined here
// Chatlog.belongsTo(models.User)
// },
},
})
return Chatlog
}
15 changes: 15 additions & 0 deletions db/models/cronjob.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
module.exports = function fn(sequelize, DataTypes) {
const Cronjob = sequelize.define('Cronjob', {
adapter: DataTypes.STRING,
userid: DataTypes.STRING,
pattern: DataTypes.STRING,
command: DataTypes.TEXT,
}, {
classMethods: {
// associate(models) {
// associations can be defined here
// },
},
})
return Cronjob
}
42 changes: 20 additions & 22 deletions db/models/index.js
Original file line number Diff line number Diff line change
@@ -1,37 +1,35 @@
'use strict';
const fs = require('fs')
const path = require('path')
const Sequelize = require('sequelize')
const fullConfig = require('../../config/db.json')

const fs = require('fs');
const path = require('path');
const Sequelize = require('sequelize');
const basename = path.basename(module.filename);
const env = process.env.NODE_ENV || 'development';
const config = require(path.join(__dirname, '..', '..', 'config', 'db.json'))[env];
var db = {};
var sequelize
const basename = path.basename(module.filename)
const env = process.env.NODE_ENV || 'development'
const config = fullConfig[env]
const db = {}
let sequelize

if (config.use_env_variable) {
sequelize = new Sequelize(process.env[config.use_env_variable]);
sequelize = new Sequelize(process.env[config.use_env_variable])
} else {
sequelize = new Sequelize(config.database, config.username, config.password, config);
sequelize = new Sequelize(config.database, config.username, config.password, config)
}

fs
.readdirSync(__dirname)
.filter((file) => {
return (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js');
})
.filter(file => (file.indexOf('.') !== 0) && (file !== basename) && (file.slice(-3) === '.js'))
.forEach((file) => {
var model = sequelize['import'](path.join(__dirname, file));
db[model.name] = model;
});
const model = sequelize.import(path.join(__dirname, file))
db[model.name] = model
})

Object.keys(db).forEach((modelName) => {
if (db[modelName].associate) {
db[modelName].associate(db);
db[modelName].associate(db)
}
});
})

db.sequelize = sequelize;
db.Sequelize = Sequelize;
db.sequelize = sequelize
db.Sequelize = Sequelize

module.exports = db;
module.exports = db
21 changes: 10 additions & 11 deletions db/models/user.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
'use strict';
module.exports = function(sequelize, DataTypes) {
var User = sequelize.define('User', {
module.exports = function fn(sequelize, DataTypes) {
const User = sequelize.define('User', {
adapter: DataTypes.STRING,
userid: DataTypes.STRING,
username: DataTypes.STRING,
profile: DataTypes.TEXT
envelope: DataTypes.TEXT,
}, {
classMethods: {
associate: function(models) {
// associations can be defined here
}
}
});
return User;
};
// associate(models) {
// associations can be defined here
// },
},
})
return User
}
3 changes: 1 addition & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
const path = require('path')
const aiva = require(path.join(__dirname, 'src', 'aiva'))
const aiva = require('./src/aiva')

if (require.main === module) {
aiva.start()
Expand Down
Loading

0 comments on commit 4e271ab

Please sign in to comment.