-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
everything #1
base: main
Are you sure you want to change the base?
everything #1
Changes from 3 commits
f3fd96f
04b8d60
e3adbcd
c7f2666
8c4299a
ae0cd0f
b5105c7
129118b
abbcadd
c8bb482
34069ff
e5b77e5
e3be2d3
d4714c1
1c39c5c
2155b51
673398e
88a1f49
bdd8eaa
e940287
188e517
76c19b3
21d704b
2deb246
8a3a94d
997625a
59073bd
dfb277a
b784072
db75351
6f961bd
098d45a
10e6b60
31c46e5
37293c4
de3b3b7
07ca507
c7d7b2e
239589c
68b33d3
856313f
e54022b
fd9b8f7
8c7ce10
2513588
a339cd2
02d4eb3
23dafdb
e298b78
0527a55
f521a3a
83aaf70
0da6e3e
6e49b8f
5b1f69a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
/node_modules/ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
ESLINT = node_modules/.bin/eslint --config node_modules/sanctuary-style/eslint-es3.json --env es3 --env node | ||
NPM = npm | ||
|
||
SCRIPTS = $(shell find scripts -name '*.js' | sort) | ||
|
||
|
||
.PHONY: lint | ||
lint: | ||
$(ESLINT) -- $(SCRIPTS) | ||
|
||
|
||
.PHONY: setup | ||
setup: | ||
$(NPM) install |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# silly-goat | ||
|
||
silly-goat is a [Hubot][1] chat bot for the [Sanctuary][2] room on [Gitter][3]. | ||
|
||
### Commands | ||
|
||
- `/versions`: list Node version and dependency versions | ||
|
||
### JavaScript evaluation | ||
|
||
When [@silly-goat][4] is mentioned in a message containing a JavaScript code | ||
block, silly-goat evaluates the code and bleats the result. | ||
|
||
In Markdown, a JavaScript code block looks like this: | ||
|
||
```javascript | ||
S.map(S.inc, [1, 2, 3]) | ||
``` | ||
|
||
`js` may be used in place of `javascript` if desired. | ||
|
||
|
||
[1]: https://hubot.github.com/ | ||
[2]: https://gitter.im/sanctuary-js/sanctuary | ||
[3]: https://gitter.im/ | ||
[4]: https://github.com/silly-goat |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
set -e | ||
|
||
PATH="node_modules/.bin:node_modules/hubot/node_modules/.bin:$PATH" \ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is from the automatically generated boilerplate. Is it required? If not, let's remove it. |
||
node_modules/.bin/hubot \ | ||
--adapter gitter2 \ | ||
--alias / \ | ||
--name silly-goat \ | ||
"$@" |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
dependencies: | ||
override: | ||
- printf '%s\n' color=false progress=false >~/.npmrc | ||
- make setup | ||
|
||
machine: | ||
node: | ||
version: 4 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity, why Node 4 instead of 6 or 7? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No good reason. Node 4 came installed on Ubuntu. For a small project it doesn't matter much to me which Node version we use so I'm happy to stick with the default. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Gotcha. In the case of a bot it might be worth it to consider updating. It would allow us to use the full set of ES6 features in the code we write. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Excellent point! I had not considered that. I'll install Node 6 on the server. :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where is the server? It would be nice to do it with infrastructure as code, maybe use a Docker container so its configuration would be in source control. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
On Linode currently.
Sounds great! This needn't happen as part of this initial pull request though. ;) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fair enough. My preference is to always put code into production with provisioning scripts. Retrofitting is always harder. |
||
|
||
test: | ||
override: | ||
- make lint |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
[] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "silly-goat", | ||
"version": "0.0.0", | ||
"private": true, | ||
"author": "David Chambers <[email protected]>", | ||
"description": "A simple helpful robot for your Company", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this description from the boilerplate? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, it was. ⚡ |
||
"dependencies": { | ||
"hubot": "2.19.0", | ||
"hubot-gitter2": "huafu/hubot-gitter2#57d5d8d23733a1925cafbcee00a0d55b98115b53", | ||
"sanctuary": "*", | ||
"sanctuary-def": "*", | ||
"sanctuary-int": "*", | ||
"sanctuary-type-classes": "*" | ||
}, | ||
"devDependencies": { | ||
"eslint": "2.9.x", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a very old version of Eslint. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is. The reason I'm specifying an old version is that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. |
||
"sanctuary-style": "0.4.x" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
'use strict'; | ||
|
||
var vm = require('vm'); | ||
|
||
var S = require('sanctuary'); | ||
var $ = require('sanctuary-def'); | ||
var Int = require('sanctuary-int'); | ||
var Z = require('sanctuary-type-classes'); | ||
|
||
|
||
// evaluate :: String -> Either Error Any | ||
var evaluate = S.encaseEither3_( | ||
S.I, | ||
vm.runInNewContext, | ||
S.__, | ||
{$: $, Int: Int, S: S, Z: Z}, | ||
{timeout: 5000} | ||
); | ||
|
||
// formatCodeBlock :: String -> String -> String | ||
var formatCodeBlock = S.curry2(function(lang, code) { | ||
return '```' + lang + '\n' + code + '\n```'; | ||
}); | ||
|
||
|
||
module.exports = function(bot) { | ||
|
||
bot.respond(/```(javascript|js)$([\s\S]*)```/m, function(res) { | ||
res.send(S.either(S.compose(formatCodeBlock('text'), S.prop('message')), | ||
S.compose(formatCodeBlock('javascript'), S.toString), | ||
evaluate(res.match[2]))); | ||
}); | ||
|
||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
var S = require('sanctuary'); | ||
|
||
var pkg = require('../package.json'); | ||
|
||
|
||
var deps = S.keys(pkg.dependencies).sort().reduce(function($acc, name) { | ||
$acc[/^hubot(-|$)/.test(name) ? 'hubot' : 'other'].push(name); | ||
return $acc; | ||
}, {hubot: [], other: []}); | ||
|
||
function version(name) { | ||
return name + '@' + require(name + '/package.json').version; | ||
} | ||
|
||
var versions = | ||
'```text\nNode ' + process.version + '\n\n' + | ||
S.unlines(S.map(version, deps.hubot)) + '\n' + | ||
S.unlines(S.map(version, deps.other)) + '```'; | ||
|
||
|
||
module.exports = function(bot) { | ||
|
||
bot.respond(/versions/, function(res) { | ||
res.send(versions); | ||
}); | ||
|
||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Npm? ;-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For now, yes. :)