Skip to content

Commit f11e5af

Browse files
authored
BREAKING CHANGES: Removed CoffeeScript support; .coffee files will no longer load (#1694)
BREAKING CHANGES: Removed es2015.js file; import index.js file instead
1 parent 5641d4c commit f11e5af

File tree

15 files changed

+83
-182
lines changed

15 files changed

+83
-182
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66

77
# Hubot
88

9+
**Please note that in v11, CoffeeScript support was removed.**
10+
911
Hubot is a framework to build chat bots, modeled after GitHub's Campfire bot of the same name, hubot.
1012
He's pretty cool. He's [extendable with scripts](https://hubotio.github.io/hubot/docs#scripts) and can work
1113
on [many different chat services](https://hubotio.github.io/hubot/adapters.html).

bin/e2e-test.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ trap "{ CODE=$?; popd; rm -rf $TEMP_ROOT; exit $CODE; }" EXIT
1212
echo "$ create hubot in $TEMP_ROOT"
1313
echo "$ install Hubot from $HUBOT_FOLDER"
1414
npm init -y
15-
npm i $HUBOT_FOLDER coffeescript
15+
npm i $HUBOT_FOLDER
1616

1717
./node_modules/.bin/hubot --create myhubot
1818
cd myhubot

bin/hubot

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
#!/usr/bin/env coffee
1+
#!/usr/bin/env node
22

3-
# While all other files have been converted to JavaScript via https://github.com/github/hubot/pull/1347,
4-
# we left the `bin/hubot` file to remain in CoffeeScript in order prevent
5-
# breaking existing 3rd party adapters of which some are still written in
6-
# CoffeeScript themselves. We will deprecate and eventually remove this file
7-
# in a future version of hubot
8-
9-
require './hubot.js'
3+
require('./hubot.js')

docs/adapters/development.md

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ permalink: /adapters/development.html
1010

1111
All adapters inherit from the Adapter class in the `src/adapter.js` file.
1212

13-
If you're writing your adapter in ES2015, you must require the ES2015 entrypoint instead:
14-
1513
```javascript
16-
const Adapter = require('hubot/es2015').Adapter;
14+
const Adapter = require('hubot/index.js').Adapter;
1715
```
1816

1917
There are certain methods that you will want to override. Here is a basic stub of what an extended Adapter class would look like:
@@ -60,10 +58,7 @@ exports.use = (robot) => new Sample(robot)
6058
"dependencies": {
6159
},
6260
"peerDependencies": {
63-
"hubot": ">=3.0"
64-
},
65-
"devDependencies": {
66-
"coffeescript": ">=1.2.0"
61+
"hubot": ">= 11"
6762
}
6863
```
6964

@@ -117,10 +112,7 @@ Another option is to load the file from local disk.
117112
"dependencies": {
118113
},
119114
"peerDependencies": {
120-
"hubot": ">=9"
121-
},
122-
"devDependencies": {
123-
"coffeescript": ">=2.7.0"
115+
"hubot": ">= 11"
124116
}
125117
```
126118

docs/deploying/azure.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,12 @@ First, run the follow command to add `deploy.cmd` to your hubot directory. This
3737

3838
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:
3939

40-
:: 4. Create Hubot file with a coffee extension
41-
copy /Y "%DEPLOYMENT_TARGET%\node_modules\hubot\bin\hubot" "%DEPLOYMENT_TARGET%\node_modules\hubot\bin\hubot.coffee"
40+
:: 4. Create Hubot file with a js extension
41+
copy /Y "%DEPLOYMENT_TARGET%\node_modules\hubot\bin\hubot" "%DEPLOYMENT_TARGET%\node_modules\hubot\bin\hubot.js"
4242

4343
Now, create a new file in the base directory of hubot called `server.js` and put these two lines into it:
4444

45-
require('coffeescript/register');
46-
module.exports = require('hubot/bin/hubot.coffee');
45+
module.exports = require('hubot/bin/hubot.js');
4746

4847
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).
4948

docs/scripting.md

Lines changed: 39 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -839,7 +839,7 @@ Listener middleware inserts logic between the listener matching a message and th
839839
840840
## Listener Middleware Examples
841841
842-
A fully functioning example can be found in [hubot-rate-limit](https://github.com/michaelansel/hubot-rate-limit/blob/master/src/rate-limit.coffee) (Note, this is a coffee version, non-async/await).
842+
A fully functioning example can be found in [hubot-rate-limit](https://github.com/michaelansel/hubot-rate-limit/blob/master/src/rate-limit.coffee) (Note: this is a coffee version, non-async/await, and will not work with the latest Hubot since CoffeeScript support was removed in version 11).
843843
844844
A simple example of middleware logging command executions:
845845
@@ -1005,51 +1005,55 @@ You may also want to install:
10051005
10061006
[Note: This section is still refering to Coffeescript, but we've update Hubot for Javascript. We'll have to replace this when we get a JavaScript example.]
10071007
1008-
Here is a sample script that tests the first couple of commands in the [Hubot sample script](https://github.com/hubotio/generator-hubot/blob/master/generators/app/templates/scripts/example.coffee). This script uses *Mocha*, *chai*, *coffeescript*, and of course *hubot-test-helper*:
1008+
Here is a sample script that tests the first couple of commands.
10091009
1010-
**test/example-test.coffee**
1010+
**test/example-test.mjs**
10111011
1012-
```coffeescript
1013-
Helper = require('hubot-test-helper')
1014-
chai = require 'chai'
1015-
1016-
expect = chai.expect
1017-
1018-
helper = new Helper('../scripts/example.coffee')
1019-
1020-
describe 'example script', ->
1021-
beforeEach ->
1022-
@room = helper.createRoom()
1012+
```javascript
1013+
import { describe, it } from 'node:test'
1014+
import assert from 'node:assert/strict'
1015+
import Helper from 'hubot-test-helper'
10231016

1024-
afterEach ->
1025-
@room.destroy()
1017+
const helper = new Helper('../scripts/example.mjs')
10261018

1027-
it 'doesn\'t need badgers', ->
1028-
@room.user.say('alice', 'did someone call for a badger?').then =>
1029-
expect(@room.messages).to.eql [
1030-
['alice', 'did someone call for a badger?']
1031-
['hubot', 'Badgers? BADGERS? WE DON\'T NEED NO STINKIN BADGERS']
1032-
]
1019+
describe('example script', () => {
1020+
let room = null
1021+
beforeEach(() => {
1022+
room = helper.createRoom()
1023+
})
10331024

1034-
it 'won\'t open the pod bay doors', ->
1035-
@room.user.say('bob', '@hubot open the pod bay doors').then =>
1036-
expect(@room.messages).to.eql [
1037-
['bob', '@hubot open the pod bay doors']
1038-
['hubot', '@bob I\'m afraid I can\'t let you do that.']
1039-
]
1025+
afterEach(() =>
1026+
room.destroy()
1027+
))
10401028

1041-
it 'will open the dutch doors', ->
1042-
@room.user.say('bob', '@hubot open the dutch doors').then =>
1043-
expect(@room.messages).to.eql [
1044-
['bob', '@hubot open the dutch doors']
1045-
['hubot', '@bob Opening dutch doors']
1046-
]
1029+
it("doesn't need badgers", async () => {
1030+
await room.user.say('alice', 'did someone call for a badger?')
1031+
assert.deepEqual(room.messages, [
1032+
['alice', 'did someone call for a badger?']
1033+
['hubot', 'Badgers? BADGERS? WE DON\'T NEED NO STINKIN BADGERS']
1034+
])
1035+
})
1036+
it("won't open the pod bay doors"), async () => {
1037+
await room.user.say('bob', '@hubot open the pod bay doors')
1038+
assert.deepEqual(room.messages, [
1039+
['bob', '@hubot open the pod bay doors']
1040+
['hubot', '@bob I\'m afraid I can\'t let you do that.']
1041+
])
1042+
})
1043+
it('will open the dutch doors'), async () => {
1044+
await room.user.say('bob', '@hubot open the dutch doors')
1045+
assert.deepEqual(room.messages, [
1046+
['bob', '@hubot open the dutch doors']
1047+
['hubot', '@bob Opening dutch doors']
1048+
])
1049+
})
1050+
}
10471051
```
10481052
10491053
**sample output**
10501054
10511055
```sh
1052-
% mocha --require coffeescript/register test/*.coffee
1056+
% node --test test/*.mjs
10531057
example script
10541058
✓ doesn't need badgers
10551059
✓ won't open the pod bay doors

es2015.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

index.js

Lines changed: 27 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,31 @@
11
'use strict'
2-
require('coffeescript/register')
32

4-
const inherits = require('util').inherits
5-
6-
const hubotExport = require('./es2015')
7-
8-
// make all es2015 class declarations compatible with CoffeeScript’s extend
9-
// see https://github.com/hubotio/evolution/pull/4#issuecomment-306437501
10-
module.exports = Object.keys(hubotExport).reduce((map, current) => {
11-
if (current !== 'loadBot') {
12-
map[current] = makeClassCoffeeScriptCompatible(hubotExport[current])
13-
} else {
14-
map[current] = hubotExport[current]
15-
}
16-
return map
17-
}, {})
18-
19-
function makeClassCoffeeScriptCompatible (klass) {
20-
function CoffeeScriptCompatibleClass () {
21-
const Hack = Function.prototype.bind.apply(klass, [null].concat([].slice.call(arguments)))
22-
const instance = new Hack()
23-
24-
// pass methods from child to returned instance
25-
for (const key in this) {
26-
instance[key] = this[key]
27-
}
28-
29-
// support for constructor methods which call super()
30-
// in which this.* properties are set
31-
for (const key in instance) {
32-
this[key] = instance[key]
33-
}
34-
35-
return instance
3+
const User = require('./src/user')
4+
const Brain = require('./src/brain')
5+
const Robot = require('./src/robot')
6+
const Adapter = require('./src/adapter')
7+
const Response = require('./src/response')
8+
const Listener = require('./src/listener')
9+
const Message = require('./src/message')
10+
const DataStore = require('./src/datastore')
11+
12+
module.exports = {
13+
User,
14+
Brain,
15+
Robot,
16+
Adapter,
17+
Response,
18+
Listener: Listener.Listener,
19+
TextListener: Listener.TextListener,
20+
Message: Message.Message,
21+
TextMessage: Message.TextMessage,
22+
EnterMessage: Message.EnterMessage,
23+
LeaveMessage: Message.LeaveMessage,
24+
TopicMessage: Message.TopicMessage,
25+
CatchAllMessage: Message.CatchAllMessage,
26+
DataStore: DataStore.DataStore,
27+
DataStoreUnavailable: DataStore.DataStoreUnavailable,
28+
loadBot (adapter, enableHttpd, name, alias) {
29+
return new module.exports.Robot(adapter, enableHttpd, name, alias)
3630
}
37-
inherits(CoffeeScriptCompatibleClass, klass)
38-
39-
return CoffeeScriptCompatibleClass
4031
}

package-lock.json

Lines changed: 0 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
"url": "https://github.com/hubotio/hubot.git"
1616
},
1717
"dependencies": {
18-
"coffeescript": "^2.7.0",
1918
"connect-multiparty": "^2.2.0",
2019
"express": "^4.18.2",
2120
"express-basic-auth": "^1.2.1",

0 commit comments

Comments
 (0)