hubot 3.3.2 → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/nodejs-macos.yml +26 -0
- package/.github/workflows/nodejs-ubuntu.yml +28 -0
- package/.github/workflows/nodejs-windows.yml +26 -0
- package/.github/workflows/release.yml +36 -0
- package/.node-version +1 -0
- package/README.md +4 -3
- package/bin/hubot +1 -1
- package/bin/hubot.js +1 -5
- package/docs/adapters/development.md +35 -36
- package/docs/deploying/windows.md +5 -5
- package/docs/implementation.md +1 -3
- package/docs/index.md +5 -10
- package/docs/patterns.md +146 -101
- package/docs/scripting.md +493 -411
- package/es2015.js +1 -1
- package/package.json +22 -21
- package/src/adapters/campfire.js +18 -18
- package/src/adapters/shell.js +11 -14
- package/src/brain.js +8 -8
- package/src/datastore.js +3 -3
- package/src/httpclient.js +312 -0
- package/src/robot.js +19 -16
- package/src/user.js +2 -2
- package/test/adapter_test.js +1 -1
- package/test/brain_test.js +9 -9
- package/test/datastore_test.js +20 -16
- package/test/es2015_test.js +1 -1
- package/test/fixtures/mock-adapter.js +5 -0
- package/test/listener_test.js +2 -2
- package/test/middleware_test.js +18 -17
- package/test/robot_test.js +28 -13
- package/test/shell_test.js +72 -0
- package/test/user_test.js +2 -2
- package/.travis.yml +0 -27
- package/ROADMAP.md +0 -37
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Node.js (macOS) CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ "master" ]
|
|
6
|
+
schedule:
|
|
7
|
+
- cron: '5 4 * * 0'
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
npm-test:
|
|
11
|
+
|
|
12
|
+
runs-on: macos-latest
|
|
13
|
+
|
|
14
|
+
strategy:
|
|
15
|
+
matrix:
|
|
16
|
+
node-version: [18.x]
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v3
|
|
20
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
21
|
+
uses: actions/setup-node@v3
|
|
22
|
+
with:
|
|
23
|
+
node-version: ${{ matrix.node-version }}
|
|
24
|
+
cache: 'npm'
|
|
25
|
+
- run: npm ci
|
|
26
|
+
- run: npm test
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
name: Node.js (Ubuntu) CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ "master" ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ "master" ]
|
|
8
|
+
schedule:
|
|
9
|
+
- cron: '5 4 * * 0'
|
|
10
|
+
|
|
11
|
+
jobs:
|
|
12
|
+
npm-test:
|
|
13
|
+
|
|
14
|
+
runs-on: ubuntu-latest
|
|
15
|
+
|
|
16
|
+
strategy:
|
|
17
|
+
matrix:
|
|
18
|
+
node-version: [14.x, 16.x, 18.x, latest]
|
|
19
|
+
|
|
20
|
+
steps:
|
|
21
|
+
- uses: actions/checkout@v3
|
|
22
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
23
|
+
uses: actions/setup-node@v3
|
|
24
|
+
with:
|
|
25
|
+
node-version: ${{ matrix.node-version }}
|
|
26
|
+
cache: 'npm'
|
|
27
|
+
- run: npm ci
|
|
28
|
+
- run: npm test
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
name: Node.js (Windows) CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ "master" ]
|
|
6
|
+
schedule:
|
|
7
|
+
- cron: '5 4 * * 0'
|
|
8
|
+
|
|
9
|
+
jobs:
|
|
10
|
+
npm-test:
|
|
11
|
+
|
|
12
|
+
runs-on: windows-latest
|
|
13
|
+
|
|
14
|
+
strategy:
|
|
15
|
+
matrix:
|
|
16
|
+
node-version: [18.x]
|
|
17
|
+
|
|
18
|
+
steps:
|
|
19
|
+
- uses: actions/checkout@v3
|
|
20
|
+
- name: Use Node.js ${{ matrix.node-version }}
|
|
21
|
+
uses: actions/setup-node@v3
|
|
22
|
+
with:
|
|
23
|
+
node-version: ${{ matrix.node-version }}
|
|
24
|
+
cache: 'npm'
|
|
25
|
+
- run: npm ci
|
|
26
|
+
- run: npm test
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
name: Release
|
|
2
|
+
on:
|
|
3
|
+
push:
|
|
4
|
+
branches:
|
|
5
|
+
- master
|
|
6
|
+
permissions:
|
|
7
|
+
contents: read
|
|
8
|
+
jobs:
|
|
9
|
+
release:
|
|
10
|
+
name: Release
|
|
11
|
+
runs-on: ubuntu-latest
|
|
12
|
+
permissions:
|
|
13
|
+
contents: write
|
|
14
|
+
issues: write
|
|
15
|
+
pull-requests: write
|
|
16
|
+
id-token: write
|
|
17
|
+
steps:
|
|
18
|
+
- name: Checkout
|
|
19
|
+
uses: actions/checkout@v3
|
|
20
|
+
with:
|
|
21
|
+
fetch-depth: 0
|
|
22
|
+
- name: Setup Node.js
|
|
23
|
+
uses: actions/setup-node@v3
|
|
24
|
+
with:
|
|
25
|
+
node-version: "lts/*"
|
|
26
|
+
- name: Install Dependencies
|
|
27
|
+
run: npm clean-install
|
|
28
|
+
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
|
|
29
|
+
run: npm audit signatures
|
|
30
|
+
- name: Run Tests
|
|
31
|
+
run: npm test
|
|
32
|
+
- name: Release
|
|
33
|
+
env:
|
|
34
|
+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
35
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
36
|
+
run: npx semantic-release
|
package/.node-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
18.16.0
|
package/README.md
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+

|
|
2
|
+

|
|
3
|
+

|
|
2
4
|
|
|
3
5
|
# Hubot
|
|
4
6
|
|
|
@@ -13,8 +15,7 @@ for details on getting up and running with your very own robot friend.
|
|
|
13
15
|
In most cases, you'll probably never have to hack on this repo directly if you
|
|
14
16
|
are building your own bot. But if you do, check out [CONTRIBUTING.md](CONTRIBUTING.md)
|
|
15
17
|
|
|
16
|
-
If you'd like to chat with Hubot users and developers, [join us on Slack](https://hubot-slackin.herokuapp.com/).
|
|
17
|
-
|
|
18
18
|
## License
|
|
19
19
|
|
|
20
20
|
See the [LICENSE](LICENSE.md) file for license rights and limitations (MIT).
|
|
21
|
+
`
|
package/bin/hubot
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
# While all other files have been converted to JavaScript via https://github.com/github/hubot/pull/1347,
|
|
4
4
|
# we left the `bin/hubot` file to remain in CoffeeScript in order prevent
|
|
5
5
|
# breaking existing 3rd party adapters of which some are still written in
|
|
6
|
-
# CoffeeScript themselves. We will
|
|
6
|
+
# CoffeeScript themselves. We will deprecate and eventually remove this file
|
|
7
7
|
# in a future version of hubot
|
|
8
8
|
|
|
9
9
|
require './hubot.js'
|
package/bin/hubot.js
CHANGED
|
@@ -23,7 +23,7 @@ const options = {
|
|
|
23
23
|
adapter: process.env.HUBOT_ADAPTER || 'shell',
|
|
24
24
|
alias: process.env.HUBOT_ALIAS || false,
|
|
25
25
|
create: process.env.HUBOT_CREATE || false,
|
|
26
|
-
enableHttpd: process.env.HUBOT_HTTPD
|
|
26
|
+
enableHttpd: process.env.HUBOT_HTTPD !== 'false',
|
|
27
27
|
scripts: process.env.HUBOT_SCRIPTS || [],
|
|
28
28
|
name: process.env.HUBOT_NAME || 'Hubot',
|
|
29
29
|
path: process.env.HUBOT_PATH || '.',
|
|
@@ -80,10 +80,6 @@ Parser.on((opt, value) => {
|
|
|
80
80
|
|
|
81
81
|
Parser.parse(process.argv)
|
|
82
82
|
|
|
83
|
-
if (process.platform !== 'win32') {
|
|
84
|
-
process.on('SIGTERM', () => process.exit(0))
|
|
85
|
-
}
|
|
86
|
-
|
|
87
83
|
if (options.create) {
|
|
88
84
|
console.error("'hubot --create' is deprecated. Use the yeoman generator instead:")
|
|
89
85
|
console.error(' npm install -g yo generator-hubot')
|
|
@@ -6,43 +6,40 @@ permalink: /docs/adapters/development/
|
|
|
6
6
|
|
|
7
7
|
## Adapter Basics
|
|
8
8
|
|
|
9
|
-
All adapters inherit from the Adapter class in the `src/adapter.
|
|
10
|
-
|
|
11
|
-
```coffee
|
|
12
|
-
Adapter = require('hubot').Adapter
|
|
13
|
-
```
|
|
9
|
+
All adapters inherit from the Adapter class in the `src/adapter.js` file.
|
|
14
10
|
|
|
15
11
|
If you're writing your adapter in ES2015, you must require the ES2015 entrypoint instead:
|
|
16
12
|
|
|
17
|
-
```
|
|
13
|
+
```javascript
|
|
18
14
|
const Adapter = require('hubot/es2015').Adapter;
|
|
19
15
|
```
|
|
20
16
|
|
|
21
17
|
There are certain methods that you will want to override. Here is a basic stub of what an extended Adapter class would look like:
|
|
22
18
|
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
19
|
+
```javascript
|
|
20
|
+
const Adapter = require('../adapter')
|
|
21
|
+
const User = require('../user')
|
|
22
|
+
const TextMessage = require('../message').TextMessage
|
|
23
|
+
class Sample extends Adapter {
|
|
24
|
+
constructor(robot) {
|
|
25
|
+
super(robot)
|
|
26
|
+
this.robot.logger.info('Constructor')
|
|
27
|
+
}
|
|
28
|
+
send(envelope, ...strings) {
|
|
29
|
+
this.robot.logger.info('Send')
|
|
30
|
+
}
|
|
31
|
+
reply(envelope, ...strings) {
|
|
32
|
+
this.robot.logger.info('Reply')
|
|
33
|
+
}
|
|
34
|
+
run() {
|
|
35
|
+
this.robot.logger.info('Run')
|
|
36
|
+
this.emit('connected')
|
|
37
|
+
const user = new User(1001, 'Sample User')
|
|
38
|
+
const message = new TextMessage(user, 'Some Sample Message', 'MSG-001')
|
|
39
|
+
this.robot.receive(message)
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.use = (robot) => new Sample(robot)
|
|
46
43
|
```
|
|
47
44
|
|
|
48
45
|
## Setting Up Your Development Environment
|
|
@@ -76,16 +73,18 @@ exports.use = (robot) ->
|
|
|
76
73
|
|
|
77
74
|
## Gotchas
|
|
78
75
|
|
|
79
|
-
There is a an open issue in the node community around [npm linked peer dependencies not working](https://github.com/npm/npm/issues/5875).
|
|
76
|
+
There is a an open issue in the node community around [npm linked peer dependencies not working](https://github.com/npm/npm/issues/5875). To get this working for our project you will need to do some minor changes to your code.
|
|
80
77
|
|
|
81
78
|
1. For the import in your `hubot-sample` adapter, add the following code
|
|
82
79
|
|
|
83
|
-
```
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
80
|
+
```javascript
|
|
81
|
+
let {Robot,Adapter,TextMessage,User} = {}
|
|
82
|
+
try {
|
|
83
|
+
{Robot,Adapter,TextMessage,User} = require('hubot')
|
|
84
|
+
} catch {
|
|
85
|
+
const prequire = require('parent-require')
|
|
86
|
+
{Robot,Adapter,TextMessage,User} = prequire('hubot')
|
|
87
|
+
}
|
|
89
88
|
```
|
|
90
89
|
2. In your `hubot-sample` folder, modify the `package.json` to include the following dependency so this custom import mechanism will work
|
|
91
90
|
|
|
@@ -8,16 +8,16 @@ Hasn't been fully tested - YMMV
|
|
|
8
8
|
|
|
9
9
|
There are 4 primary steps to deploying and running hubot on a Windows machine:
|
|
10
10
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
* node and npm
|
|
12
|
+
* a way to get source code updated on the server
|
|
13
|
+
* setting up environment variables for hubot
|
|
14
|
+
* a way to start hubot, start it up if it crashes, and restart it when code updates
|
|
15
15
|
|
|
16
16
|
## node and npm
|
|
17
17
|
|
|
18
18
|
To start, your windows server will need node and npm.
|
|
19
19
|
The best way to do this is with [chocolatey](http://chocolatey.org) using the [nodejs.install](http://chocolatey.org/packages/nodejs.install) package.
|
|
20
|
-
I've found that sometimes the system path variable is not correctly set; ensure you can run node/npm from the command line. If needed set the PATH variable with
|
|
20
|
+
I've found that sometimes the system path variable is not correctly set; ensure you can run node/npm from the command line. If needed set the PATH variable with `set PATH=%PATH%;\"C:\Program Files\nodejs\"`
|
|
21
21
|
|
|
22
22
|
Your other option is to install directly from [NodeJS](https://nodejs.org/) and run the current download (v0.12.4 as of this documentation). This should set your PATH variables for you.
|
|
23
23
|
|
package/docs/implementation.md
CHANGED
|
@@ -43,9 +43,7 @@ Furthermore, Hubot scripts exist to enable persistence across Hubot restarts.
|
|
|
43
43
|
`hubot-redis-brain` is such a script and uses a backend Redis server.
|
|
44
44
|
|
|
45
45
|
By default, the brain contains a list of all users seen by Hubot.
|
|
46
|
-
Therefore, without persistence across restarts, the brain will contain the list of users encountered so far, during the current run of Hubot.
|
|
47
|
-
On the other hand, with persistence across restarts, the brain will contain all users encountered by Hubot during all of its runs.
|
|
48
|
-
This list of users can be accessed through `hubot.brain.users()` and other utility methods.
|
|
46
|
+
Therefore, without persistence across restarts, the brain will contain the list of users encountered so far, during the current run of Hubot. On the other hand, with persistence across restarts, the brain will contain all users encountered by Hubot during all of its runs. This list of users can be accessed through `hubot.brain.users()` and other utility methods.
|
|
49
47
|
|
|
50
48
|
### Datastore
|
|
51
49
|
|
package/docs/index.md
CHANGED
|
@@ -44,15 +44,12 @@ You now have your own functional hubot! There's a `bin/hubot`
|
|
|
44
44
|
command for convenience, to handle installing npm dependencies, loading scripts,
|
|
45
45
|
and then launching your hubot.
|
|
46
46
|
|
|
47
|
-
Hubot
|
|
47
|
+
Note: Hubot can use Redis to persist data, so before you can start hubot on your own computer, if you want to persist data, then you should have Redis running on your machine accessible via `localhost`. Then, ensure that `hubot-redis-brain` is listed in `external-scripts.json` as an `Array` of module names (e.g. `['hubot-redis-brain']`) or an `object` where the key is the name of the module (e.g. `{'hubot-redis-brain': 'some arbitrary value'}`) where the value of the property in the object is passed to the module function as the second argument. The first argument being the hubot Robot instance.
|
|
48
48
|
|
|
49
49
|
% bin/hubot
|
|
50
50
|
Hubot>
|
|
51
51
|
|
|
52
|
-
This starts hubot using the [shell adapter](./adapters/shell.md), which
|
|
53
|
-
is mostly useful for development. Make note of the name in the `hubot>` prompt;
|
|
54
|
-
this is the name your hubot will respond to with commands. If the prompt
|
|
55
|
-
reads `myhubot>` then your commands must start with `myhubot <command>`
|
|
52
|
+
This starts hubot using the [shell adapter](./adapters/shell.md), which is mostly useful for development. Make note of the name in the `hubot>` prompt; this is the name your hubot will respond to with commands. If the prompt reads `myhubot>` then your commands must start with `myhubot <command>`.
|
|
56
53
|
|
|
57
54
|
For example, to list available commands:
|
|
58
55
|
|
|
@@ -107,7 +104,7 @@ To use a script from an NPM package:
|
|
|
107
104
|
2. Add the package to `external-scripts.json`.
|
|
108
105
|
3. Run `npm home <package-name>` to open a browser window for the homepage of the script, where you can find more information about configuring and installing the script.
|
|
109
106
|
|
|
110
|
-
You can also put your own scripts under the `scripts/` directory. All scripts placed there are automatically loaded and ready to use with your hubot. Read more about customizing hubot by [writing your own scripts](scripting.md).
|
|
107
|
+
You can also put your own scripts under the `scripts/` directory. All scripts (files ending with either `.js` or `.mjs`) placed there are automatically loaded and ready to use with your hubot. Read more about customizing hubot by [writing your own scripts](scripting.md).
|
|
111
108
|
|
|
112
109
|
## Adapters
|
|
113
110
|
|
|
@@ -115,9 +112,7 @@ Hubot uses the adapter pattern to support multiple chat-backends. Here is a [lis
|
|
|
115
112
|
|
|
116
113
|
## Deploying
|
|
117
114
|
|
|
118
|
-
You can deploy hubot to Heroku, which is the officially supported method.
|
|
119
|
-
Additionally you are able to deploy hubot to a UNIX-like system or Windows.
|
|
120
|
-
Please note the support for deploying to Windows isn't officially supported.
|
|
115
|
+
You can deploy hubot to Heroku, which is the officially supported method. Additionally you are able to deploy hubot to a UNIX-like system or Windows. Please note the support for deploying to Windows isn't officially supported.
|
|
121
116
|
|
|
122
117
|
* [Deploying Hubot onto Azure](./deploying/azure.md)
|
|
123
118
|
* [Deploying Hubot onto Bluemix](./deploying/bluemix.md)
|
|
@@ -127,4 +122,4 @@ Please note the support for deploying to Windows isn't officially supported.
|
|
|
127
122
|
|
|
128
123
|
## Patterns
|
|
129
124
|
|
|
130
|
-
Using custom scripts, you can quickly customize Hubot to be the most life embettering robot he or she can be. Read [docs/patterns.md](patterns.md) for some nifty tricks that may come in handy as you teach your hubot new skills.
|
|
125
|
+
Using custom scripts, you can quickly customize Hubot to be the most life embettering robot he or she can be. Read [docs/patterns.md](patterns.md) for some nifty tricks that may come in handy as you teach your hubot new skills.
|