chore: create skeleton of the bot

This commit is contained in:
Odonno 2017-09-05 13:58:28 +02:00
Коммит 34e1822d9f
4 изменённых файлов: 163 добавлений и 0 удалений

64
.gitignore поставляемый Normal file
Просмотреть файл

@ -0,0 +1,64 @@
# Created by https://www.gitignore.io/api/node
### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
# nyc test coverage
.nyc_output
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Typescript v1 declaration files
typings/
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
# End of https://www.gitignore.io/api/node

76
index.ts Normal file
Просмотреть файл

@ -0,0 +1,76 @@
import haunt = require('haunt');
const start = (username: string, password: string, repositoryUrl: string, tests: any) => {
haunt.auth(username, password);
haunt.repo({
repo: repositoryUrl,
tests: tests
}, () => {
console.log('running tests');
});
}
const tests = {
'pull-requests': {
'should send a message of linked non-closed issues when a PR is merged': (pr) => {
if (pr.state !== 'closed') {
// TODO : check if PR is merged
// TODO : do not send a new message if one has already been added
// TODO : get issues from `pr.issue_url`
// TODO : check if there are unclosed issues
// TODO : send a message with links to unclosed issues
}
}
},
'issues': {
'should detect if there was no response from the community after a period of time': (issue) => {
if (issue.state !== 'closed') {
// TODO : check if there is only one user who write a message (the creator of the message)
// TODO : check if the issue contains an exclusive labels
// TODO : check if the first message was sent 7 days ago
// TODO : send a message with a ping to the team
}
},
'should send a reminder after a period of time, up to 2 successive alerts': (issue) => {
if (issue.state !== 'closed') {
// TODO : check if at least two users write a message
// TODO : check if the issue contains an exclusive labels
// TODO : check if last message was sent 7 days ago
// TODO : check if last messages of the issue contains less than 2 successive messages of the bot
// TODO : send a message to the creator of the issue that issue will be close in X days
}
},
'should close the issue after 3 successive alerts': (issue) => {
if (issue.state !== 'closed') {
// TODO : check if at least two users write a message
// TODO : check if the issue contains an exclusive labels
// TODO : check if last message was sent 7 days ago
// TODO : check if last messages of the issue contains exactly 2 successive messages of the bot
// TODO : close issue and send a message that issue got no answer from the creator
}
}
}
}
// TODO : execute CRON task
// TODO : use env variables
start('user', 'pass', 'http://github.com/my/repo', tests);

7
package.json Normal file
Просмотреть файл

@ -0,0 +1,7 @@
{
"name": "github-bot-uwp-toolkit",
"version": "0.1.0",
"dependencies": {
"haunt": "^1.1.0"
}
}

16
tsconfig.json Normal file
Просмотреть файл

@ -0,0 +1,16 @@
{
"compileOnSave": true,
"compilerOptions": {
"allowUnreachableCode": false,
"alwaysStrict": true,
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"removeComments": true,
"sourceMap": true,
"target": "es5"
},
"exclude": [ "node_modules" ]
}