hubot 5.0.4 → 5.0.6
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/package.json +1 -1
- package/src/robot.js +0 -11
- package/.editorconfig +0 -14
- package/.github/stale.yml +0 -23
- package/.github/workflows/nodejs-macos.yml +0 -26
- package/.github/workflows/nodejs-ubuntu.yml +0 -28
- package/.github/workflows/nodejs-windows.yml +0 -26
- package/.github/workflows/release.yml +0 -37
- package/bin/e2e-test.sh +0 -47
- package/docs/adapters/campfire.md +0 -79
- package/docs/adapters/development.md +0 -125
- package/docs/adapters/shell.md +0 -24
- package/docs/adapters.md +0 -27
- package/docs/deploying/azure.md +0 -97
- package/docs/deploying/bluemix.md +0 -111
- package/docs/deploying/heroku.md +0 -66
- package/docs/deploying/unix.md +0 -72
- package/docs/deploying/windows.md +0 -66
- package/docs/deploying.md +0 -11
- package/docs/implementation.md +0 -55
- package/docs/index.md +0 -125
- package/docs/patterns.md +0 -265
- package/docs/scripting.md +0 -1051
- package/examples/hubot-start.ps1 +0 -12
- package/examples/hubot.service +0 -27
- package/script/bootstrap +0 -3
- package/script/release +0 -44
- package/script/server +0 -3
- package/script/smoke-test +0 -3
- package/script/test +0 -3
- package/test/adapter_test.js +0 -97
- package/test/brain_test.js +0 -336
- package/test/datastore_test.js +0 -154
- package/test/es2015_test.js +0 -199
- package/test/fixtures/MockAdapter.coffee +0 -10
- package/test/fixtures/MockAdapter.mjs +0 -43
- package/test/fixtures/TestScript.coffee +0 -9
- package/test/fixtures/TestScript.js +0 -13
- package/test/fixtures/mock-adapter.js +0 -35
- package/test/listener_test.js +0 -379
- package/test/message_test.js +0 -46
- package/test/middleware_test.js +0 -507
- package/test/robot_test.js +0 -1153
- package/test/shell_test.js +0 -73
- package/test/user_test.js +0 -29
package/package.json
CHANGED
package/src/robot.js
CHANGED
|
@@ -389,17 +389,6 @@ class Robot {
|
|
|
389
389
|
}
|
|
390
390
|
}
|
|
391
391
|
|
|
392
|
-
// Public: Load scripts specified in the `hubot-scripts.json` file.
|
|
393
|
-
//
|
|
394
|
-
// path - A String path to the hubot-scripts files.
|
|
395
|
-
// scripts - An Array of scripts to load.
|
|
396
|
-
//
|
|
397
|
-
// Returns nothing.
|
|
398
|
-
loadHubotScripts (path, scripts) {
|
|
399
|
-
this.logger.debug(`Loading hubot-scripts from ${path}`)
|
|
400
|
-
Array.from(scripts).map(script => this.loadFile(path, script))
|
|
401
|
-
}
|
|
402
|
-
|
|
403
392
|
// Public: Load scripts from packages specified in the
|
|
404
393
|
// `external-scripts.json` file.
|
|
405
394
|
//
|
package/.editorconfig
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
# EditorConfig is awesome: http://EditorConfig.org
|
|
2
|
-
|
|
3
|
-
# Top-most EditorConfig file
|
|
4
|
-
root = true
|
|
5
|
-
|
|
6
|
-
# Match and apply these rules for all file
|
|
7
|
-
# types you open in your code editor
|
|
8
|
-
[*]
|
|
9
|
-
# Unix-style newlines
|
|
10
|
-
end_of_line = lf
|
|
11
|
-
insert_final_newline = true
|
|
12
|
-
indent_style = space
|
|
13
|
-
indent_size = 2
|
|
14
|
-
trim_trailing_whitespace = true
|
package/.github/stale.yml
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
# Configuration for probot-stale - https://github.com/probot/stale
|
|
2
|
-
|
|
3
|
-
# Number of days of inactivity before an Issue or Pull Request becomes stale
|
|
4
|
-
daysUntilStale: 90
|
|
5
|
-
# Number of days of inactivity before a stale Issue or Pull Request is closed
|
|
6
|
-
daysUntilClose: 7
|
|
7
|
-
# Issues or Pull Requests with these labels will never be considered stale
|
|
8
|
-
exemptLabels:
|
|
9
|
-
- pinned
|
|
10
|
-
- security
|
|
11
|
-
# Label to use when marking as stale
|
|
12
|
-
staleLabel: stale
|
|
13
|
-
# Comment to post when marking as stale. Set to `false` to disable
|
|
14
|
-
markComment: >
|
|
15
|
-
This issue has been automatically marked as stale because it has [not had
|
|
16
|
-
recent activity](https://github.com/github/hubot/blob/main/CONTRIBUTING.md#stale-issue-and-pull-request-policy).
|
|
17
|
-
It will be closed if no further activity occurs. Thank you for your contributions.
|
|
18
|
-
# Comment to post when removing the stale label. Set to `false` to disable
|
|
19
|
-
unmarkComment: false
|
|
20
|
-
# Comment to post when closing a stale Issue or Pull Request. Set to `false` to disable
|
|
21
|
-
closeComment: false
|
|
22
|
-
# Limit to only `issues` or `pulls`
|
|
23
|
-
# only: issues
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
name: Node.js (macOS) CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [ "main" ]
|
|
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
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
name: Node.js (Ubuntu) CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [ "main" ]
|
|
6
|
-
pull_request:
|
|
7
|
-
branches: [ "main" ]
|
|
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
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
name: Node.js (Windows) CI
|
|
2
|
-
|
|
3
|
-
on:
|
|
4
|
-
push:
|
|
5
|
-
branches: [ "main" ]
|
|
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
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
name: Release
|
|
2
|
-
on:
|
|
3
|
-
push:
|
|
4
|
-
branches:
|
|
5
|
-
- main
|
|
6
|
-
- next
|
|
7
|
-
permissions:
|
|
8
|
-
contents: read
|
|
9
|
-
jobs:
|
|
10
|
-
release:
|
|
11
|
-
name: Release
|
|
12
|
-
runs-on: ubuntu-latest
|
|
13
|
-
permissions:
|
|
14
|
-
contents: write
|
|
15
|
-
issues: write
|
|
16
|
-
pull-requests: write
|
|
17
|
-
id-token: write
|
|
18
|
-
steps:
|
|
19
|
-
- name: Checkout
|
|
20
|
-
uses: actions/checkout@v3
|
|
21
|
-
with:
|
|
22
|
-
fetch-depth: 0
|
|
23
|
-
- name: Setup Node.js
|
|
24
|
-
uses: actions/setup-node@v3
|
|
25
|
-
with:
|
|
26
|
-
node-version: "lts/*"
|
|
27
|
-
- name: Install Dependencies
|
|
28
|
-
run: npm clean-install
|
|
29
|
-
- name: Verify the integrity of provenance attestations and registry signatures for installed dependencies
|
|
30
|
-
run: npm audit signatures
|
|
31
|
-
- name: Run Tests
|
|
32
|
-
run: npm test
|
|
33
|
-
- name: Release
|
|
34
|
-
env:
|
|
35
|
-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
36
|
-
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
37
|
-
run: npx semantic-release
|
package/bin/e2e-test.sh
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
HUBOT_FOLDER=$(pwd)
|
|
3
|
-
TEMP_ROOT=$(mktemp -d)
|
|
4
|
-
|
|
5
|
-
echo "$ pushd $TEMP_ROOT"
|
|
6
|
-
pushd $TEMP_ROOT
|
|
7
|
-
trap "{ CODE=$?; popd; rm -rf $TEMP_ROOT; exit $CODE; }" EXIT
|
|
8
|
-
|
|
9
|
-
## https://hubot.github.com/docs/
|
|
10
|
-
|
|
11
|
-
echo "$ npm install -g yo generator-hubot"
|
|
12
|
-
npm install -g yo generator-hubot
|
|
13
|
-
|
|
14
|
-
## simulate pressing enter for each generator question to accept defaults
|
|
15
|
-
## https://stackoverflow.com/a/6264618/206879
|
|
16
|
-
echo "$ yo hubot --defaults"
|
|
17
|
-
yo hubot --defaults
|
|
18
|
-
|
|
19
|
-
## use hubot from last commit
|
|
20
|
-
echo "$ npm install $HUBOT_FOLDER"
|
|
21
|
-
npm install $HUBOT_FOLDER
|
|
22
|
-
|
|
23
|
-
# npm install /path/to/hubot will create a symlink in npm 5+ (http://blog.npmjs.org/post/161081169345/v500).
|
|
24
|
-
# As the require calls for app-specific scripts happen inside hubot, we have to
|
|
25
|
-
# set NODE_PATH to the app’s node_modules path so they can be found
|
|
26
|
-
echo "$ NODE_PATH=$HUBOT_FOLDER/node_modules:$TEMP_ROOT/node_modules"
|
|
27
|
-
export NODE_PATH=$NODE_PATH/$HUBOT_FOLDER/node_modules:$TEMP_ROOT/node_modules
|
|
28
|
-
|
|
29
|
-
## start
|
|
30
|
-
expect <<EOL
|
|
31
|
-
set timeout 30
|
|
32
|
-
|
|
33
|
-
spawn bin/hubot --name e2etest
|
|
34
|
-
|
|
35
|
-
# workaround for current hubot which does not show prompt until pressed enter
|
|
36
|
-
# so we simulate it once 'INFO hubot-redis-brain: Using default redis on localhost:6379' appears
|
|
37
|
-
expect "localhost:6379"
|
|
38
|
-
send "\r"
|
|
39
|
-
|
|
40
|
-
expect "e2etest> "
|
|
41
|
-
|
|
42
|
-
send "e2etest ping\r"
|
|
43
|
-
expect {
|
|
44
|
-
"PONG" {}
|
|
45
|
-
timeout {exit 1}
|
|
46
|
-
}
|
|
47
|
-
EOL
|
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
permalink: /docs/adapters/campfire/
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Campfire adapter
|
|
6
|
-
|
|
7
|
-
[Campfire](http://campfirenow.com/) is a web based chat application built by
|
|
8
|
-
[37signals](http://37signals.com). The Campfire adapter is one of the original
|
|
9
|
-
adapters in Hubot.
|
|
10
|
-
|
|
11
|
-
## Getting Started
|
|
12
|
-
|
|
13
|
-
You will need a Campfire account to start, which you can
|
|
14
|
-
[sign up for free](https://signup.37signals.com/campfire/free/signup/new).
|
|
15
|
-
|
|
16
|
-
Next, you will need to create a user on your Campfire account for your Hubot,
|
|
17
|
-
then give it access so it can join to your rooms. You will need to create a room
|
|
18
|
-
if you haven't already.
|
|
19
|
-
|
|
20
|
-
Hubot defaults to using its [shell](./shell.md), so to use Campfire instead, you
|
|
21
|
-
can run hubot with `-a campfire`:
|
|
22
|
-
|
|
23
|
-
% bin/hubot -a campfire
|
|
24
|
-
|
|
25
|
-
If you are deploying to Heroku or using foreman, you need to make
|
|
26
|
-
sure the hubot is called with `-a campfire` in the `Procfile`:
|
|
27
|
-
|
|
28
|
-
web: bin/hubot -a campfire -n Hubot
|
|
29
|
-
|
|
30
|
-
## Configuring
|
|
31
|
-
|
|
32
|
-
The adapter requires the following environment variables.
|
|
33
|
-
|
|
34
|
-
* `HUBOT_CAMPFIRE_ACCOUNT`
|
|
35
|
-
* `HUBOT_CAMPFIRE_TOKEN`
|
|
36
|
-
* `HUBOT_CAMPFIRE_ROOMS`
|
|
37
|
-
|
|
38
|
-
### Campfire API Token
|
|
39
|
-
|
|
40
|
-
This can be found by logging in with your hubot's account click the **My Info**
|
|
41
|
-
link and make a note of the API token.
|
|
42
|
-
|
|
43
|
-
### Campfire Room IDs
|
|
44
|
-
|
|
45
|
-
If you join the rooms you want your hubot to join will see notice a numerical
|
|
46
|
-
ID for the room in the URL. Make a note of each ID for the rooms you want your
|
|
47
|
-
hubot to join.
|
|
48
|
-
|
|
49
|
-
### Campfire Account
|
|
50
|
-
|
|
51
|
-
This is simply the first part of the domain you visit for your Campfire
|
|
52
|
-
account. For example if your Campfire was at `hubot.campfirenow.com` your
|
|
53
|
-
subdomain is `hubot`. Make a note of the subdomain.
|
|
54
|
-
|
|
55
|
-
### Configuring the variables on Heroku
|
|
56
|
-
|
|
57
|
-
% heroku config:set HUBOT_CAMPFIRE_TOKEN="..."
|
|
58
|
-
|
|
59
|
-
% heroku config:set HUBOT_CAMPFIRE_ROOMS="123,321"
|
|
60
|
-
|
|
61
|
-
% heroku config:set HUBOT_CAMPFIRE_ACCOUNT="..."
|
|
62
|
-
|
|
63
|
-
### Configuring the variables on UNIX
|
|
64
|
-
|
|
65
|
-
% export HUBOT_CAMPFIRE_TOKEN="..."
|
|
66
|
-
|
|
67
|
-
% export HUBOT_CAMPFIRE_ROOMS="123,321"
|
|
68
|
-
|
|
69
|
-
% export HUBOT_CAMPFIRE_ACCOUNT="..."
|
|
70
|
-
|
|
71
|
-
### Configuring the variables on Windows
|
|
72
|
-
|
|
73
|
-
Using PowerShell:
|
|
74
|
-
|
|
75
|
-
setx HUBOT_CAMPFIRE_TOKEN "..." /m
|
|
76
|
-
|
|
77
|
-
setx HUBOT_CAMPFIRE_ROOMS "123,321" /m
|
|
78
|
-
|
|
79
|
-
setx HUBOT_CAMPFIRE_ACCOUNT "..." /m
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
permalink: /docs/adapters/development/
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Development adapter
|
|
6
|
-
|
|
7
|
-
## Adapter Basics
|
|
8
|
-
|
|
9
|
-
All adapters inherit from the Adapter class in the `src/adapter.js` file.
|
|
10
|
-
|
|
11
|
-
If you're writing your adapter in ES2015, you must require the ES2015 entrypoint instead:
|
|
12
|
-
|
|
13
|
-
```javascript
|
|
14
|
-
const Adapter = require('hubot/es2015').Adapter;
|
|
15
|
-
```
|
|
16
|
-
|
|
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:
|
|
18
|
-
|
|
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') // The 'connected' event is required to trigger loading of Hubot scripts.
|
|
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)
|
|
43
|
-
```
|
|
44
|
-
|
|
45
|
-
## Option 1. Setting Up Your Development Environment
|
|
46
|
-
|
|
47
|
-
1. Create a new folder for your adapter `hubot-sample`
|
|
48
|
-
- `mkdir hubot-sample`
|
|
49
|
-
2. Change your working directory to `hubot-sample`
|
|
50
|
-
- `cd hubot-sample`
|
|
51
|
-
3. Run `npm init` to create your package.json
|
|
52
|
-
- make sure the entry point is `src/sample.js`
|
|
53
|
-
4. Add your `.gitignore` to include `node_modules`
|
|
54
|
-
5. Edit the `src/sample.js` file to include the above stub for your adapter
|
|
55
|
-
6. Edit the `package.json` to add a peer dependency on `hubot`
|
|
56
|
-
|
|
57
|
-
```json
|
|
58
|
-
"dependencies": {
|
|
59
|
-
},
|
|
60
|
-
"peerDependencies": {
|
|
61
|
-
"hubot": ">=3.0"
|
|
62
|
-
},
|
|
63
|
-
"devDependencies": {
|
|
64
|
-
"coffeescript": ">=1.2.0"
|
|
65
|
-
}
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
7. Generate your Hubot using the `yo hubot` [command](https://hubot.github.com/docs/)
|
|
69
|
-
8. Change working directories to the `hubot` you created in step 7.
|
|
70
|
-
9. Now perform an `npm link` to add your adapter to `hubot`
|
|
71
|
-
- `npm link ../hubot-sample`
|
|
72
|
-
10. Run `hubot -a sample`
|
|
73
|
-
|
|
74
|
-
## Gotchas
|
|
75
|
-
|
|
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.
|
|
77
|
-
|
|
78
|
-
1. For the import in your `hubot-sample` adapter, add the following code
|
|
79
|
-
|
|
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
|
-
}
|
|
88
|
-
```
|
|
89
|
-
2. In your `hubot-sample` folder, modify the `package.json` to include the following dependency so this custom import mechanism will work
|
|
90
|
-
|
|
91
|
-
```json
|
|
92
|
-
"dependencies": {
|
|
93
|
-
"parent-require": "^1.0.0"
|
|
94
|
-
}
|
|
95
|
-
```
|
|
96
|
-
3. Now try running `hubot -a sample` again and see that the imports are properly loaded.
|
|
97
|
-
4. Once this is working properly, you can build out the functionality of your adapter as you see fit. Take a look at some of the other adapters to get some ideas for your implementation.
|
|
98
|
-
- Once packaged and deployed via `npm`, you won't need the dependency in `hubot` anymore since the peer dependency should work as an official module.
|
|
99
|
-
|
|
100
|
-
## Option 2. Setting Up Your Development Environment
|
|
101
|
-
|
|
102
|
-
Another option is to load the file from local disk.
|
|
103
|
-
|
|
104
|
-
1. Create a new folder for your adapter `hubot-sample`
|
|
105
|
-
- `mkdir hubot-sample`
|
|
106
|
-
2. Change your working directory to `hubot-sample`
|
|
107
|
-
- `cd hubot-sample`
|
|
108
|
-
3. Run `npm init` to create your package.json
|
|
109
|
-
- make sure the entry point is `src/sample.js`
|
|
110
|
-
4. Add your `.gitignore` to include `node_modules`
|
|
111
|
-
5. Edit the `src/sample.js` file to include the above stub for your adapter
|
|
112
|
-
6. Edit the `package.json` to add a peer dependency on `hubot`
|
|
113
|
-
|
|
114
|
-
```json
|
|
115
|
-
"dependencies": {
|
|
116
|
-
},
|
|
117
|
-
"peerDependencies": {
|
|
118
|
-
"hubot": ">=4.2.0"
|
|
119
|
-
},
|
|
120
|
-
"devDependencies": {
|
|
121
|
-
"coffeescript": ">=1.2.0"
|
|
122
|
-
}
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
7. Run `npx hubot -p ./src -a sample.js`
|
package/docs/adapters/shell.md
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
permalink: /docs/adapters/shell/
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Shell adapter
|
|
6
|
-
|
|
7
|
-
The shell adapter provides a simple read-eval-print loop for interacting with a hubot locally.
|
|
8
|
-
It can be useful for testing scripts before using them on a live hubot.
|
|
9
|
-
|
|
10
|
-
## Getting Started
|
|
11
|
-
|
|
12
|
-
To use the shell adapter you can simply omit the `-a` option when running
|
|
13
|
-
hubot as it will use the shell adapter by default.
|
|
14
|
-
|
|
15
|
-
% bin/hubot
|
|
16
|
-
|
|
17
|
-
## Configuring
|
|
18
|
-
|
|
19
|
-
This adapter doesn't require any configuration.
|
|
20
|
-
|
|
21
|
-
It supports two environment variables to make it possible to test scripts as different users:
|
|
22
|
-
|
|
23
|
-
* HUBOT_SHELL_USER_ID: default is 1
|
|
24
|
-
* HUBOT_SHELL_USER_NAME: default is Shell
|
package/docs/adapters.md
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
permalink: /docs/adapters/
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Adapters
|
|
6
|
-
|
|
7
|
-
Adapters are the interface to the service you want your hubot to run on.
|
|
8
|
-
|
|
9
|
-
Hubot includes two official adapters:
|
|
10
|
-
|
|
11
|
-
* [Shell](./adapters/shell.md), i.e. for use with development
|
|
12
|
-
* [Campfire](./adapters/campfire.md)
|
|
13
|
-
|
|
14
|
-
There are Third-party adapters available for most chat services. Here are the most popular ones:
|
|
15
|
-
|
|
16
|
-
* [Gitter](https://github.com/huafu/hubot-gitter2)
|
|
17
|
-
* [HipChat](https://github.com/hipchat/hubot-hipchat)
|
|
18
|
-
* [IRC](https://github.com/nandub/hubot-irc)
|
|
19
|
-
* [Rocket.Chat](https://github.com/RocketChat/hubot-rocketchat)
|
|
20
|
-
* [Slack](https://github.com/slackhq/hubot-slack)
|
|
21
|
-
* [XMPP](https://github.com/markstory/hubot-xmpp)
|
|
22
|
-
|
|
23
|
-
Browse all [repositories with the `hubot-adapter` topic on GitHub](https://github.com/search?q=topic%3Ahubot-adapter&type=Repositories) or [search for adapters on NPM](https://www.npmjs.com/search?q=hubot%20adapter&ranking=popularity). Add the `hubot-adapter` [topic](https://help.github.com/articles/classifying-your-repository-with-topics/) to your repository on GitHub to include it in this list.
|
|
24
|
-
|
|
25
|
-
## Writing Your Own Adapter
|
|
26
|
-
|
|
27
|
-
Interested in adding your own adapter? Check out our documentation for [developing adapters](./adapters/development.md)
|
package/docs/deploying/azure.md
DELETED
|
@@ -1,97 +0,0 @@
|
|
|
1
|
-
---
|
|
2
|
-
permalink: /docs/deploying/azure/
|
|
3
|
-
---
|
|
4
|
-
|
|
5
|
-
# Deploying to Azure
|
|
6
|
-
|
|
7
|
-
If you've been following along with [Getting Started](../index.md), it's time to deploy so you can use it beyond just your local machine.
|
|
8
|
-
[Azure](http://azure.microsoft.com/) is a way to deploy hubot as an alternative to [Heroku](heroku.md).
|
|
9
|
-
|
|
10
|
-
You will need to install the azure-cli via npm after you have follow the initial instructions for your hubot.
|
|
11
|
-
|
|
12
|
-
% npm install -g azure-cli
|
|
13
|
-
|
|
14
|
-
Inside your new hubot directory, make sure you've created a git repository, and that your work is committed:
|
|
15
|
-
|
|
16
|
-
% git init
|
|
17
|
-
% git add .
|
|
18
|
-
% git commit -m "Initial commit"
|
|
19
|
-
|
|
20
|
-
Then [create a GitHub repository](https://help.github.com/articles/create-a-repo/) for your hubot. This is where Azure will pull your code from instead of needing to deploy directly from your dev machine to Azure.
|
|
21
|
-
|
|
22
|
-
% git remote add origin _your GitHub repo_
|
|
23
|
-
% git push -u origin main
|
|
24
|
-
|
|
25
|
-
Once you have your GitHub repo, create an Azure website linked to your repo. In Azure, create a website and select integrated source control. When it asks "where is your source control" select GitHub and link this website to your git repo that you created in the previous step. If you have downloaded the Azure PowerShell modules, you can also do this via PowerShell.
|
|
26
|
-
|
|
27
|
-
% $creds = Get-Credential
|
|
28
|
-
% New-AzureWebsite mynewhubot -github -githubrepository yourgithubaccount/yourhubotreponame -githubcredentials $creds
|
|
29
|
-
|
|
30
|
-
Once you have done this, Azure will deploy your site any time you commit and push to GitHub. Your hubot won't run quite right yet, though. Next, you need to configure the deployment to tell Azure how to run hubot.
|
|
31
|
-
|
|
32
|
-
First, run the follow command to add `deploy.cmd` to your hubot directory. This is the file that Azure uses to know how to deploy your node application.
|
|
33
|
-
|
|
34
|
-
% azure site deploymentscript --node
|
|
35
|
-
|
|
36
|
-
Then, edit this file and look for the sections that give you steps 1, 2 and 3. You're going to add a 4th step:
|
|
37
|
-
|
|
38
|
-
:: 4. Create Hubot file with a coffee extension
|
|
39
|
-
copy /Y "%DEPLOYMENT_TARGET%\node_modules\hubot\bin\hubot" "%DEPLOYMENT_TARGET%\node_modules\hubot\bin\hubot.coffee"
|
|
40
|
-
|
|
41
|
-
Now, create a new file in the base directory of hubot called `server.js` and put these two lines into it:
|
|
42
|
-
|
|
43
|
-
require('coffeescript/register');
|
|
44
|
-
module.exports = require('hubot/bin/hubot.coffee');
|
|
45
|
-
|
|
46
|
-
Finally you will need to add the environment variables to the website to make sure it runs properly. You can either do it through the GUI (under configuration) or you can use the Azure PowerShell command line, as follows (example is showing slack as an adapter and mynewhubot as the website name).
|
|
47
|
-
|
|
48
|
-
% $settings = New-Object Hashtable
|
|
49
|
-
% $settings["HUBOT_ADAPTER"] = "Slack"
|
|
50
|
-
% $settings["HUBOT_SLACK_TOKEN"] = "yourslackapikey"
|
|
51
|
-
% Set-AzureWebsite -AppSettings $settings mynewhubot
|
|
52
|
-
|
|
53
|
-
Commit your changes in git and push to GitHub and Azure will automatically pick up the changes and deploy them to your website.
|
|
54
|
-
|
|
55
|
-
% git commit -m "Add Azure settings for hubot"
|
|
56
|
-
% git push
|
|
57
|
-
|
|
58
|
-
Azure offers a marketplace where you can use the default heroku-redis-brain using Redis Cloud provided by Redis Labs. Alternatively, to add an [Azure blob storage brain](https://github.com/coryallegory/hubot-azure-brain), you will need to create an Azure storage account. Then you can do the following in your base hubot directory.
|
|
59
|
-
|
|
60
|
-
% npm install hubot-azure-brain --save
|
|
61
|
-
|
|
62
|
-
Then add the following line in `external-scripts.json` in the list with the other external scripts
|
|
63
|
-
|
|
64
|
-
"hubot-azure-brain"
|
|
65
|
-
|
|
66
|
-
Finally, add one more environment variables to your website. You can do this either via the GUI or the following PowerShell commands.
|
|
67
|
-
|
|
68
|
-
% $settings = New-Object Hashtable
|
|
69
|
-
% $settings["HUBOT_BRAIN_AZURE_CONNSTRING"] = "your Azure blob storage connection string"
|
|
70
|
-
% Set-AzureWebsite -AppSettings $settings mynewhubot
|
|
71
|
-
|
|
72
|
-
Now any scripts that require a brain will function. You should look up other scripts or write your own by looking at the [documentation](../scripting.md). All of the normal scripts for hubot are compatible with hosting hubot on Azure.
|
|
73
|
-
|
|
74
|
-
### Troubleshooting tips and tricks
|
|
75
|
-
|
|
76
|
-
Due to Azure being Windows-based, you may run into path length problems. To overcome this issue you can set the environment variable `IN_PLACE_DEPLOYMENT` to `1` and use [custom deployment scripts to take advantage of NPM3](https://github.com/felixrieseberg/azure-npm3) and flat module installation.
|
|
77
|
-
|
|
78
|
-
If you have your instance of hubot deploying directly from source control to Azure, it will perform various bootstrapping tasks along with calling `npm install` via kudu. Now that Azure supports npm5, this process generates a package-lock.json file which may result in some of your packages failing to install remotely. You can edit `deploy.cmd` to include `--no-package-lock` as part of the "Step 3" install command.
|
|
79
|
-
|
|
80
|
-
If using the free tier of Azure, you can also add a post-deployment step to ping the server on startup by setting the environment variable `POST_DEPLOYMENT_ACTION` with a script (relative to the src dir) such as `startup.sh`
|
|
81
|
-
|
|
82
|
-
An example of a startup script:
|
|
83
|
-
|
|
84
|
-
```
|
|
85
|
-
let retrys=0
|
|
86
|
-
while : ; do
|
|
87
|
-
STATUSCODE=$(curl --silent --output /dev/stderr --write-out "%{http_code}" https://${WEBSITE_SITE_NAME}.azurewebsites.net/heroku/keepalive)
|
|
88
|
-
echo $STATUSCODE
|
|
89
|
-
[[ $retrys -ne 5 ]] || break
|
|
90
|
-
echo $retrys
|
|
91
|
-
((retrys++))
|
|
92
|
-
[[ $STATUSCODE -ne 200 ]] || break
|
|
93
|
-
done
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
### Slack Integration
|
|
97
|
-
Currently the Slack integration has trouble finding hubot when deployed to Azure. Adding a `NODE_PATH` application setting with the value `D:\home\site\wwwroot\node_modules` will allow the Slack module to find hubot.
|