Skip to content
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

Open
wants to merge 55 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
f3fd96f
everything
davidchambers Feb 18, 2017
04b8d60
add circle.yml
davidchambers Feb 18, 2017
e3adbcd
circle: try ~/.npmrc
davidchambers Feb 18, 2017
c7f2666
circle: remove ineffectual line
davidchambers Feb 18, 2017
8c4299a
package.json: remove boilerplate
davidchambers Feb 18, 2017
ae0cd0f
add dockerfile
davidchambers Feb 19, 2017
b5105c7
Node v6.x.x
davidchambers Feb 19, 2017
129118b
eval: make the language specifier optional
davidchambers Feb 19, 2017
abbcadd
move start-up command to package.json
davidchambers Feb 19, 2017
c8bb482
prepend node_modules/.bin to PATH so coffee can be found
davidchambers Feb 19, 2017
34069ff
remove external-scripts.json
davidchambers Feb 19, 2017
e5b77e5
remove makefile in favour of npm scripts
davidchambers Feb 19, 2017
e3be2d3
update circle.yml
davidchambers Feb 19, 2017
d4714c1
dockerfile: combine RUN commands
davidchambers Feb 19, 2017
1c39c5c
scripts: use {foo, bar, baz} sugar
davidchambers Feb 19, 2017
2155b51
scripts: use sanctuary-def
davidchambers Feb 19, 2017
673398e
scripts: use dependency version from package.json unless value is "*"
davidchambers Feb 19, 2017
88a1f49
add Ramda
davidchambers Feb 27, 2017
bdd8eaa
support console.log
davidchambers Feb 27, 2017
e940287
[email protected]
davidchambers Apr 3, 2017
188e517
circle: upgrade to CircleCI 2.0
davidchambers Oct 27, 2017
76c19b3
[email protected]
davidchambers Oct 27, 2017
21d704b
fix package versions
davidchambers Dec 23, 2017
2deb246
prevent syntax highlighting of version information
davidchambers Dec 23, 2017
8a3a94d
use S.encaseEither3 rather than S.encaseEither3_
davidchambers Jan 5, 2018
997625a
[email protected]
davidchambers Mar 13, 2018
59073bd
[email protected]
davidchambers May 28, 2018
dfb277a
create custom Sanctuary module to permit the use of Descending
davidchambers May 29, 2018
b784072
[email protected]
davidchambers May 29, 2018
db75351
[email protected]
davidchambers Jun 8, 2018
6f961bd
[email protected]
davidchambers Jun 8, 2018
098d45a
[email protected]
davidchambers Jun 8, 2018
10e6b60
remove stray semicolon
davidchambers Jun 8, 2018
31c46e5
nodesource/node:10
davidchambers Nov 29, 2018
37293c4
add Fluture
davidchambers Feb 5, 2019
de3b3b7
support console.error
davidchambers Feb 5, 2019
07ca507
[email protected]
davidchambers Feb 17, 2019
c7d7b2e
[email protected]
davidchambers Mar 9, 2019
239589c
[email protected]
davidchambers Mar 9, 2019
68b33d3
[email protected]
davidchambers Apr 5, 2019
856313f
[email protected]
davidchambers Apr 27, 2019
e54022b
[email protected]
davidchambers Oct 24, 2019
fd9b8f7
[email protected]
davidchambers Nov 3, 2019
8c7ce10
add FUNDING.yml
davidchambers Jan 1, 2020
2513588
circle: housekeeping
davidchambers Jan 2, 2020
a339cd2
[email protected]
davidchambers Jan 3, 2020
02d4eb3
[email protected]
davidchambers Jan 13, 2020
23dafdb
[email protected]
davidchambers Jan 20, 2020
e298b78
[email protected]
davidchambers May 3, 2020
0527a55
eval: use fluture-sanctuary-types
davidchambers May 3, 2020
f521a3a
eval: fix $Useless
davidchambers May 3, 2020
83aaf70
[email protected]
davidchambers Aug 10, 2020
0da6e3e
eval: use S.show to show logged values
davidchambers May 4, 2021
6e49b8f
circle: update Node version
davidchambers Dec 6, 2023
5b1f69a
circle: update Node version
davidchambers Oct 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/node_modules/
14 changes: 14 additions & 0 deletions Makefile
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Npm? ;-)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For now, yes. :)


SCRIPTS = $(shell find scripts -name '*.js' | sort)


.PHONY: lint
lint:
$(ESLINT) -- $(SCRIPTS)


.PHONY: setup
setup:
$(NPM) install
26 changes: 26 additions & 0 deletions README.md
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
9 changes: 9 additions & 0 deletions bin/hubot
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" \
Copy link
Member Author

Choose a reason for hiding this comment

The 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 \
"$@"
12 changes: 12 additions & 0 deletions circle.yml
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Out of curiosity, why Node 4 instead of 6 or 7?

Copy link
Member Author

Choose a reason for hiding this comment

The 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.

Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The 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. :)

Copy link
Member

Choose a reason for hiding this comment

The 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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is the server?

On Linode currently.

It would be nice to do it with infrastructure as code, maybe use a Docker container so its configuration would be in source control.

Sounds great! This needn't happen as part of this initial pull request though. ;)

Copy link
Member

Choose a reason for hiding this comment

The 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
1 change: 1 addition & 0 deletions external-scripts.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
19 changes: 19 additions & 0 deletions package.json
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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this description from the boilerplate?

Copy link
Member Author

Choose a reason for hiding this comment

The 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",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very old version of Eslint.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is. The reason I'm specifying an old version is that [email protected] does not make use of any rules added since [email protected]. We should update sanctuary-style to the latest version of ESLint then update both dependencies at once (here and in other projects).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good.

"sanctuary-style": "0.4.x"
}
}
34 changes: 34 additions & 0 deletions scripts/eval.js
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])));
});

};
29 changes: 29 additions & 0 deletions scripts/versions.js
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);
});

};