hubot 9.1.0 → 9.1.1

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/LICENSE.md CHANGED
@@ -1,4 +1,4 @@
1
- Copyright (c) 2011-2017 GitHub Inc.
1
+ Copyright (c) 2011-2023 GitHub Inc.
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
package/README.md CHANGED
@@ -1,3 +1,5 @@
1
+ ![Pipeline Status](https://github.com/hubotio/hubot/actions/workflows/pipeline.yml/badge.svg)
2
+
1
3
  ![Build Status: MacOS](https://github.com/hubotio/hubot/actions/workflows/nodejs-macos.yml/badge.svg)
2
4
  ![Build Status: Ubuntu](https://github.com/hubotio/hubot/actions/workflows/nodejs-ubuntu.yml/badge.svg)
3
5
  ![Build Status: Window](https://github.com/hubotio/hubot/actions/workflows/nodejs-windows.yml/badge.svg)
@@ -5,11 +7,11 @@
5
7
  # Hubot
6
8
 
7
9
  Hubot is a framework to build chat bots, modeled after GitHub's Campfire bot of the same name, hubot.
8
- He's pretty cool. He's [extendable with scripts](http://hubot.github.com/docs/#scripts) and can work
9
- on [many different chat services](https://hubot.github.com/docs/adapters/).
10
+ He's pretty cool. He's [extendable with scripts](https://hubotio.github.io/hubot/docs#scripts) and can work
11
+ on [many different chat services](https://hubotio.github.io/hubot/adapters.html).
10
12
 
11
13
  This repository provides a library that's distributed by `npm` that you
12
- use for building your own bots. See the [documentation](http://hubot.github.com/docs)
14
+ use for building your own bots. See the [documentation](https://hubotio.github.io/hubot/docs.html)
13
15
  for details on getting up and running with your very own robot friend.
14
16
 
15
17
  In most cases, you'll probably never have to hack on this repo directly if you
@@ -17,9 +19,9 @@ are building your own bot. But if you do, check out [CONTRIBUTING.md](CONTRIBUTI
17
19
 
18
20
  # Create your own Hubot instance
19
21
 
22
+ This will create a directory called `myhubot` in the current working directory.
23
+
20
24
  ```sh
21
- mkdir myhubot
22
- cd myhubot
23
25
  npx hubot --create myhubot --adapter @hubot-friends/hubot-slack
24
26
  ```
25
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hubot",
3
- "version": "9.1.0",
3
+ "version": "9.1.1",
4
4
  "author": "hubot",
5
5
  "keywords": [
6
6
  "github",
@@ -40,7 +40,9 @@
40
40
  "pretest": "standard",
41
41
  "test": "node --test",
42
42
  "test:smoke": "node src/**/*.js",
43
- "test:e2e": "bin/e2e-test.sh"
43
+ "test:e2e": "bin/e2e-test.sh",
44
+ "build:local": "npx @hubot-friends/sfab --folder ./docs --destination ./_site --verbose --serve /hubot/ --watch-path ./docs --scripts ./sfab-hooks",
45
+ "build": "npx @hubot-friends/sfab --folder ./docs --destination ./_site --verbose --scripts ./sfab-hooks"
44
46
  },
45
47
  "release": {
46
48
  "branches": [
@@ -0,0 +1,11 @@
1
+ export default () => {
2
+ return {
3
+ model (file, model) {
4
+ return {
5
+ base: {
6
+ href: '/hubot/'
7
+ }
8
+ }
9
+ }
10
+ }
11
+ }
package/src/robot.js CHANGED
@@ -37,6 +37,7 @@ class Robot {
37
37
  this.brain = new Brain(this)
38
38
  this.alias = alias
39
39
  this.adapter = null
40
+ this.shouldEnableHttpd = httpd ?? true
40
41
  this.datastore = null
41
42
  this.Response = Response
42
43
  this.commands = []
@@ -55,18 +56,13 @@ class Robot {
55
56
  this.globalHttpOptions = {}
56
57
 
57
58
  this.parseVersion()
58
- if (httpd) {
59
- this.setupExpress()
60
- } else {
61
- this.setupNullRouter()
62
- }
63
-
64
59
  this.adapterName = adapter ?? 'shell'
65
60
  this.errorHandlers = []
66
61
 
67
62
  this.on('error', (err, res) => {
68
63
  return this.invokeErrorHandlers(err, res)
69
64
  })
65
+ this.on('listening', this.herokuKeepalive.bind(this))
70
66
  }
71
67
 
72
68
  // Public: Adds a custom Listener with the provided matcher, options, and
@@ -407,8 +403,8 @@ class Robot {
407
403
 
408
404
  // Setup the Express server's defaults.
409
405
  //
410
- // Returns nothing.
411
- setupExpress () {
406
+ // Returns Server.
407
+ async setupExpress () {
412
408
  const user = process.env.EXPRESS_USER
413
409
  const pass = process.env.EXPRESS_PASSWORD
414
410
  const stat = process.env.EXPRESS_STATIC
@@ -444,27 +440,18 @@ class Robot {
444
440
  if (stat) {
445
441
  app.use(express.static(stat))
446
442
  }
447
-
448
- try {
449
- this.server = app.listen(port, address)
450
- this.router = app
451
- } catch (error) {
452
- this.logger.error(`Error trying to start HTTP server: ${error}\n${error.stack}`)
453
- throw error
454
- }
455
-
456
- let herokuUrl = process.env.HEROKU_URL
457
-
458
- if (herokuUrl) {
459
- if (!/\/$/.test(herokuUrl)) {
460
- herokuUrl += '/'
461
- }
462
- this.pingIntervalId = setInterval(() => {
463
- HttpClient.create(`${herokuUrl}hubot/ping`).post()((_err, res, body) => {
464
- this.logger.info('keep alive ping!')
443
+ const p = new Promise((resolve, reject) => {
444
+ try {
445
+ this.server = app.listen(port, address, () => {
446
+ this.router = app
447
+ this.emit('listening', this.server)
448
+ resolve(this.server)
465
449
  })
466
- }, 5 * 60 * 1000)
467
- }
450
+ } catch (err) {
451
+ reject(err)
452
+ }
453
+ })
454
+ return p
468
455
  }
469
456
 
470
457
  // Setup an empty router object
@@ -645,6 +632,11 @@ class Robot {
645
632
  //
646
633
  // Returns whatever the adapter returns.
647
634
  async run () {
635
+ if (this.shouldEnableHttpd) {
636
+ await this.setupExpress()
637
+ } else {
638
+ this.setupNullRouter()
639
+ }
648
640
  this.emit('running')
649
641
 
650
642
  return await this.adapter.run()
@@ -712,6 +704,20 @@ class Robot {
712
704
 
713
705
  return HttpClient.create(url, httpOptions).header('User-Agent', `Hubot/${this.version}`)
714
706
  }
707
+
708
+ herokuKeepalive (server) {
709
+ let herokuUrl = process.env.HEROKU_URL
710
+ if (herokuUrl) {
711
+ if (!/\/$/.test(herokuUrl)) {
712
+ herokuUrl += '/'
713
+ }
714
+ this.pingIntervalId = setInterval(() => {
715
+ HttpClient.create(`${herokuUrl}hubot/ping`).post()((_err, res, body) => {
716
+ this.logger.info('keep alive ping!')
717
+ })
718
+ }, 5 * 60 * 1000)
719
+ }
720
+ }
715
721
  }
716
722
 
717
723
  module.exports = Robot