hubot 10.0.4 → 10.0.5

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/README.md CHANGED
@@ -6,7 +6,9 @@
6
6
 
7
7
  # Hubot
8
8
 
9
- **Please note that in v11, CoffeeScript support was removed.**
9
+ **Note: v10.0.4 contains the removal of CoffeeScript**
10
+
11
+ Semver is looking for **BREAKING CHANGE** singular, not **BREAKING CHANGES**. As a result, the removal of CoffeeScript was marked as the `v10.0.4` release.
10
12
 
11
13
  Hubot is a framework to build chat bots, modeled after GitHub's Campfire bot of the same name, hubot.
12
14
  He's pretty cool. He's [extendable with scripts](https://hubotio.github.io/hubot/docs#scripts) and can work
package/bin/hubot CHANGED
@@ -1,3 +1,9 @@
1
- #!/usr/bin/env node
1
+ #!/usr/bin/env coffee
2
2
 
3
- require('./hubot.js')
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'
package/es2015.js ADDED
@@ -0,0 +1,31 @@
1
+ 'use strict'
2
+
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)
30
+ }
31
+ }
package/index.js CHANGED
@@ -1,31 +1,40 @@
1
1
  'use strict'
2
+ require('coffeescript/register')
2
3
 
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)
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
30
36
  }
37
+ inherits(CoffeeScriptCompatibleClass, klass)
38
+
39
+ return CoffeeScriptCompatibleClass
31
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hubot",
3
- "version": "10.0.4",
3
+ "version": "10.0.5",
4
4
  "author": "hubot",
5
5
  "keywords": [
6
6
  "github",
@@ -15,6 +15,7 @@
15
15
  "url": "https://github.com/hubotio/hubot.git"
16
16
  },
17
17
  "dependencies": {
18
+ "coffeescript": "^2.7.0",
18
19
  "connect-multiparty": "^2.2.0",
19
20
  "express": "^4.18.2",
20
21
  "express-basic-auth": "^1.2.1",
package/src/robot.js CHANGED
@@ -328,6 +328,10 @@ class Robot {
328
328
  }
329
329
  }
330
330
 
331
+ async loadcoffee (filePath) {
332
+ return await this.loadjs(filePath)
333
+ }
334
+
331
335
  async loadjs (filePath) {
332
336
  const script = require(filePath)
333
337
  if (typeof script === 'function') {
@@ -348,7 +352,7 @@ class Robot {
348
352
  const full = path.join(filepath, path.basename(filename))
349
353
 
350
354
  // see https://github.com/hubotio/hubot/issues/1355
351
- if (['js', 'mjs'].indexOf(ext) === -1) {
355
+ if (['js', 'mjs', 'coffee'].indexOf(ext) === -1) {
352
356
  this.logger.debug(`Skipping unsupported file type ${full}`)
353
357
  return
354
358
  }
@@ -476,7 +480,7 @@ class Robot {
476
480
  try {
477
481
  if (Array.from(HUBOT_DEFAULT_ADAPTERS).indexOf(this.adapterName) > -1) {
478
482
  this.adapter = this.requireAdapterFrom(path.resolve(path.join(__dirname, 'adapters', this.adapterName)))
479
- } else if (['.js', '.cjs'].includes(ext)) {
483
+ } else if (['.js', '.cjs', '.coffee'].includes(ext)) {
480
484
  this.adapter = this.requireAdapterFrom(path.resolve(adapterPath))
481
485
  } else if (['.mjs'].includes(ext)) {
482
486
  this.adapter = await this.importAdapterFrom(pathToFileURL(path.resolve(adapterPath)).href)