hubot 10.0.4 → 11.0.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/README.md CHANGED
@@ -6,7 +6,8 @@
6
6
 
7
7
  # Hubot
8
8
 
9
- **Please note that in v11, CoffeeScript support was removed.**
9
+ **Note: v10.0.4 accidentaly contains the removal of CoffeeScript; v10.0.5 puts it back in**
10
+ **Note: v11 removes CoffeeScript and converts this codebase to ESM**
10
11
 
11
12
  Hubot is a framework to build chat bots, modeled after GitHub's Campfire bot of the same name, hubot.
12
13
  He's pretty cool. He's [extendable with scripts](https://hubotio.github.io/hubot/docs#scripts) and can work
@@ -1,15 +1,13 @@
1
1
  'use strict'
2
2
 
3
- const fs = require('fs')
4
- const pathResolve = require('path').resolve
5
-
6
- const OptParse = require('../src/OptParse.js')
7
-
8
- const Hubot = require('..')
9
- const create = require('../src/GenHubot.js')
3
+ import fs from 'node:fs'
4
+ import { resolve as pathResolve } from 'node:path'
5
+ import OptParse from '../src/OptParse.mjs'
6
+ import Hubot from '../index.mjs'
7
+ import create from '../src/GenHubot.mjs'
10
8
 
11
9
  const switches = [
12
- ['-a', '--adapter HUBOT_ADAPTER', 'The Adapter to use, e.g. "shell" (to load the default hubot shell adapter)'],
10
+ ['-a', '--adapter HUBOT_ADAPTER', 'The Adapter to use, e.g. "Shell" (to load the default hubot Shell adapter)'],
13
11
  ['-f', '--file HUBOT_FILE', 'Path to adapter file, e.g. "./adapters/CustomAdapter.mjs"'],
14
12
  ['-c', '--create HUBOT_CREATE', 'Create a deployable hubot'],
15
13
  ['-d', '--disable-httpd HUBOT_HTTPD', 'Disable the HTTP server'],
@@ -97,13 +95,13 @@ if (options.file) {
97
95
  }
98
96
 
99
97
  const robot = Hubot.loadBot(options.adapter, options.enableHttpd, options.name, options.alias)
100
- module.exports = robot
98
+ export default robot
101
99
 
102
100
  async function loadScripts () {
103
101
  await robot.load(pathResolve('.', 'scripts'))
104
102
  await robot.load(pathResolve('.', 'src', 'scripts'))
105
103
 
106
- loadExternalScripts()
104
+ await loadExternalScripts()
107
105
 
108
106
  const tasks = options.scripts.map((scriptPath) => {
109
107
  if (scriptPath[0] === '/') {
@@ -115,25 +113,19 @@ async function loadScripts () {
115
113
  await Promise.all(tasks)
116
114
  }
117
115
 
118
- function loadExternalScripts () {
116
+ async function loadExternalScripts () {
119
117
  const externalScripts = pathResolve('.', 'external-scripts.json')
120
-
121
- if (!fs.existsSync(externalScripts)) {
122
- return
123
- }
124
-
125
- fs.readFile(externalScripts, function (error, data) {
126
- if (error) {
127
- throw error
128
- }
129
-
118
+ try {
119
+ const data = await fs.promises.readFile(externalScripts)
130
120
  try {
131
121
  robot.loadExternalScripts(JSON.parse(data))
132
122
  } catch (error) {
133
123
  console.error(`Error parsing JSON data from external-scripts.json: ${error}`)
134
124
  process.exit(1)
135
125
  }
136
- })
126
+ } catch (e) {
127
+ robot.logger.info('No external-scripts.json found. Skipping.')
128
+ }
137
129
  }
138
130
 
139
131
  (async () => {
package/bin/hubot CHANGED
@@ -1,3 +1,3 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- require('./hubot.js')
3
+ import('./Hubot.mjs').then(async ({ default: robot }) => {})
package/index.mjs ADDED
@@ -0,0 +1,52 @@
1
+ 'use strict'
2
+
3
+ import User from './src/User.mjs'
4
+ import Brain from './src/Brain.mjs'
5
+ import Robot from './src/Robot.mjs'
6
+ import Adapter from './src/Adapter.mjs'
7
+ import Response from './src/Response.mjs'
8
+ import Middleware from './src/Middleware.mjs'
9
+ import { Listener, TextListener } from './src/Listener.mjs'
10
+ import { TextMessage, EnterMessage, LeaveMessage, TopicMessage, CatchAllMessage, Message } from './src/Message.mjs'
11
+ import { DataStore, DataStoreUnavailable } from './src/DataStore.mjs'
12
+
13
+ const loadBot = (adapter, enableHttpd, name, alias) => new Robot(adapter, enableHttpd, name, alias)
14
+ export {
15
+ Adapter,
16
+ User,
17
+ Brain,
18
+ Robot,
19
+ Response,
20
+ Listener,
21
+ TextListener,
22
+ Message,
23
+ TextMessage,
24
+ EnterMessage,
25
+ LeaveMessage,
26
+ TopicMessage,
27
+ CatchAllMessage,
28
+ DataStore,
29
+ DataStoreUnavailable,
30
+ Middleware,
31
+ loadBot
32
+ }
33
+
34
+ export default {
35
+ Adapter,
36
+ User,
37
+ Brain,
38
+ Robot,
39
+ Response,
40
+ Listener,
41
+ TextListener,
42
+ Message,
43
+ TextMessage,
44
+ EnterMessage,
45
+ LeaveMessage,
46
+ TopicMessage,
47
+ CatchAllMessage,
48
+ DataStore,
49
+ DataStoreUnavailable,
50
+ Middleware,
51
+ loadBot
52
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hubot",
3
- "version": "10.0.4",
3
+ "version": "11.0.0",
4
4
  "author": "hubot",
5
5
  "keywords": [
6
6
  "github",
@@ -27,7 +27,7 @@
27
27
  "node": ">= 18",
28
28
  "npm": ">= 9"
29
29
  },
30
- "main": "./index",
30
+ "main": "./index.mjs",
31
31
  "bin": {
32
32
  "hubot": "./bin/hubot"
33
33
  },
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const EventEmitter = require('events').EventEmitter
3
+ import EventEmitter from 'node:events'
4
4
 
5
5
  class Adapter extends EventEmitter {
6
6
  // An adapter is a specific interface to a chat source for robots.
@@ -136,4 +136,4 @@ class Adapter extends EventEmitter {
136
136
  }
137
137
  }
138
138
 
139
- module.exports = Adapter
139
+ export default Adapter
@@ -1,8 +1,7 @@
1
1
  'use strict'
2
2
 
3
- const EventEmitter = require('events').EventEmitter
4
-
5
- const User = require('./user')
3
+ import EventEmitter from 'node:events'
4
+ import User from './User.mjs'
6
5
 
7
6
  // If necessary, reconstructs a User object. Returns either:
8
7
  //
@@ -239,4 +238,4 @@ class Brain extends EventEmitter {
239
238
  }
240
239
  }
241
240
 
242
- module.exports = Brain
241
+ export default Brain
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- class DataStore {
3
+ export class DataStore {
4
4
  // Represents a persistent, database-backed storage for the robot. Extend this.
5
5
  //
6
6
  // Returns a new Datastore with no storage.
@@ -83,9 +83,9 @@ class DataStore {
83
83
  }
84
84
  }
85
85
 
86
- class DataStoreUnavailable extends Error {}
86
+ export class DataStoreUnavailable extends Error {}
87
87
 
88
- module.exports = {
88
+ export default {
89
89
  DataStore,
90
90
  DataStoreUnavailable
91
91
  }
@@ -1,6 +1,6 @@
1
- const { spawnSync } = require('child_process')
2
- const File = require('fs')
3
- const path = require('path')
1
+ import { spawnSync } from 'node:child_process'
2
+ import File from 'node:fs'
3
+ import path from 'node:path'
4
4
 
5
5
  function runCommands (hubotDirectory, options) {
6
6
  options.hubotInstallationPath = options?.hubotInstallationPath ?? 'hubot'
@@ -13,8 +13,19 @@ function runCommands (hubotDirectory, options) {
13
13
  const envFilePath = path.resolve(process.cwd(), '.env')
14
14
  process.chdir(hubotDirectory)
15
15
 
16
- spawnSync('npm', ['init', '-y'])
17
- spawnSync('npm', ['i', options.hubotInstallationPath].concat(options.adapter, 'hubot-help', 'hubot-rules', 'hubot-diagnostics'))
16
+ let output = spawnSync('npm', ['init', '-y'])
17
+ console.log('npm init', output.stderr.toString())
18
+ if (options.hubotInstallationPath !== 'hubot') {
19
+ output = spawnSync('npm', ['pack', `${options.hubotInstallationPath}`])
20
+ console.log('npm pack', output.stderr.toString(), output.stdout.toString())
21
+ const customHubotPackage = JSON.parse(File.readFileSync(`${options.hubotInstallationPath}/package.json`, 'utf8'))
22
+ output = spawnSync('npm', ['i', `${customHubotPackage.name}-${customHubotPackage.version}.tgz`])
23
+ console.log(`npm i ${customHubotPackage.name}-${customHubotPackage.version}.tgz`, output.stderr.toString(), output.stdout.toString())
24
+ } else {
25
+ output = spawnSync('npm', ['i', 'hubot@latest'])
26
+ }
27
+ output = spawnSync('npm', ['i', 'hubot-help@latest', 'hubot-rules@latest', 'hubot-diagnostics@latest'].concat([options.adapter]).filter(Boolean))
28
+ console.log('npm i', output.stderr.toString(), output.stdout.toString())
18
29
  spawnSync('mkdir', ['scripts'])
19
30
  spawnSync('touch', ['external-scripts.json'])
20
31
 
@@ -50,6 +61,7 @@ export default (robot) => {
50
61
  packageJson.scripts = {
51
62
  start: 'hubot'
52
63
  }
64
+ packageJson.description = 'A simple helpful robot for your Company'
53
65
  if (options.adapter) {
54
66
  packageJson.scripts.start += ` --adapter ${options.adapter}`
55
67
  }
@@ -79,7 +91,7 @@ export default (robot) => {
79
91
  console.log('.env file not found, continuing to the next operation.')
80
92
  }
81
93
  }
82
- module.exports = (hubotDirectory, options) => {
94
+ export default (hubotDirectory, options) => {
83
95
  try {
84
96
  runCommands(hubotDirectory, options)
85
97
  } catch (error) {
@@ -33,10 +33,10 @@ Implement a phased approach to deprecate `robot.http` all together in favor of `
33
33
  2. Add a deprecation warning to `robot.http`
34
34
  3. Remove `robot.http` in a future release
35
35
  */
36
- const path = require('path')
37
- const http = require('http')
38
- const https = require('https')
39
- const qs = require('querystring')
36
+ import path from 'node:path'
37
+ import http from 'node:http'
38
+ import https from 'node:https'
39
+ import qs from 'node:querystring'
40
40
 
41
41
  const nonPassThroughOptions = [
42
42
  'headers', 'hostname', 'encoding', 'auth', 'port',
@@ -308,5 +308,8 @@ const reduce = function (a, b) {
308
308
  }
309
309
  return a
310
310
  }
311
-
312
- exports.create = (url, options) => new ScopedClient(url, options)
311
+ export default {
312
+ create (url, options) {
313
+ return new ScopedClient(url, options)
314
+ }
315
+ }
@@ -1,9 +1,8 @@
1
1
  'use strict'
2
2
 
3
- const inspect = require('util').inspect
4
-
5
- const TextMessage = require('./message').TextMessage
6
- const Middleware = require('./middleware')
3
+ import { inspect } from 'node:util'
4
+ import { TextMessage } from './Message.mjs'
5
+ import Middleware from './Middleware.mjs'
7
6
 
8
7
  class Listener {
9
8
  // Listeners receive every message from the chat source and decide if they
@@ -108,7 +107,7 @@ class TextListener extends Listener {
108
107
  }
109
108
  }
110
109
 
111
- module.exports = {
110
+ export {
112
111
  Listener,
113
112
  TextListener
114
113
  }
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- class Message {
3
+ export class Message {
4
4
  // Represents an incoming message from the chat.
5
5
  //
6
6
  // user - A User instance that sent the message.
@@ -18,7 +18,7 @@ class Message {
18
18
  }
19
19
  }
20
20
 
21
- class TextMessage extends Message {
21
+ export class TextMessage extends Message {
22
22
  // Represents an incoming message from the chat.
23
23
  //
24
24
  // user - A User instance that sent the message.
@@ -52,23 +52,23 @@ class TextMessage extends Message {
52
52
  // user - A User instance for the user who entered.
53
53
  // text - Always null.
54
54
  // id - A String of the message ID.
55
- class EnterMessage extends Message {}
55
+ export class EnterMessage extends Message {}
56
56
 
57
57
  // Represents an incoming user exit notification.
58
58
  //
59
59
  // user - A User instance for the user who left.
60
60
  // text - Always null.
61
61
  // id - A String of the message ID.
62
- class LeaveMessage extends Message {}
62
+ export class LeaveMessage extends Message {}
63
63
 
64
64
  // Represents an incoming topic change notification.
65
65
  //
66
66
  // user - A User instance for the user who changed the topic.
67
67
  // text - A String of the new topic
68
68
  // id - A String of the message ID.
69
- class TopicMessage extends TextMessage {}
69
+ export class TopicMessage extends TextMessage {}
70
70
 
71
- class CatchAllMessage extends Message {
71
+ export class CatchAllMessage extends Message {
72
72
  // Represents a message that no matchers matched.
73
73
  //
74
74
  // message - The original message.
@@ -78,7 +78,7 @@ class CatchAllMessage extends Message {
78
78
  }
79
79
  }
80
80
 
81
- module.exports = {
81
+ export default {
82
82
  Message,
83
83
  TextMessage,
84
84
  EnterMessage,
@@ -42,4 +42,4 @@ class Middleware {
42
42
  }
43
43
  }
44
44
 
45
- module.exports = Middleware
45
+ export default Middleware
@@ -1,4 +1,4 @@
1
- const EventEmitter = require('node:events')
1
+ import EventEmitter from 'node:events'
2
2
  class OptParse extends EventEmitter {
3
3
  constructor (switches) {
4
4
  super()
@@ -41,4 +41,4 @@ ${this.switches.map(([key, description]) => ` ${key}, ${description}`).join('\n
41
41
  }
42
42
  }
43
43
 
44
- module.exports = OptParse
44
+ export default OptParse
@@ -123,4 +123,4 @@ class Response {
123
123
  }
124
124
  }
125
125
 
126
- module.exports = Response
126
+ export default Response
@@ -1,21 +1,23 @@
1
1
  'use strict'
2
- const EventEmitter = require('events').EventEmitter
3
- const fs = require('fs')
4
- const path = require('path')
5
- const pathToFileURL = require('url').pathToFileURL
6
2
 
7
- const pino = require('pino')
8
- const HttpClient = require('./httpclient')
9
-
10
- const Brain = require('./brain')
11
- const Response = require('./response')
12
- const Listener = require('./listener')
13
- const Message = require('./message')
14
- const Middleware = require('./middleware')
15
-
16
- const HUBOT_DEFAULT_ADAPTERS = ['campfire', 'shell']
3
+ import EventEmitter from 'node:events'
4
+ import fs from 'node:fs'
5
+ import path from 'node:path'
6
+ import { pathToFileURL, fileURLToPath } from 'node:url'
7
+ import pino from 'pino'
8
+ import HttpClient from './HttpClient.mjs'
9
+ import Brain from './Brain.mjs'
10
+ import Response from './Response.mjs'
11
+ import { Listener, TextListener } from './Listener.mjs'
12
+ import Message from './Message.mjs'
13
+ import Middleware from './Middleware.mjs'
14
+
15
+ const HUBOT_DEFAULT_ADAPTERS = ['Campfire', 'Shell']
17
16
  const HUBOT_DOCUMENTATION_SECTIONS = ['description', 'dependencies', 'configuration', 'commands', 'notes', 'author', 'authors', 'examples', 'tags', 'urls']
18
17
 
18
+ const __filename = fileURLToPath(import.meta.url)
19
+ const __dirname = path.dirname(__filename)
20
+
19
21
  class Robot {
20
22
  // Robots receive messages from a chat source (Campfire, irc, etc), and
21
23
  // dispatch them to matching listeners.
@@ -37,6 +39,14 @@ class Robot {
37
39
  this.brain = new Brain(this)
38
40
  this.alias = alias
39
41
  this.adapter = null
42
+ this.adaptername = 'Shell'
43
+ if (adapter && typeof (adapter) === 'object') {
44
+ this.adapter = adapter
45
+ this.adapterName = adapter.name ?? adapter.constructor.name
46
+ } else {
47
+ this.adapterName = adapter ?? this.adaptername
48
+ }
49
+
40
50
  this.shouldEnableHttpd = httpd ?? true
41
51
  this.datastore = null
42
52
  this.Response = Response
@@ -56,7 +66,6 @@ class Robot {
56
66
  this.globalHttpOptions = {}
57
67
 
58
68
  this.parseVersion()
59
- this.adapterName = adapter ?? 'shell'
60
69
  this.errorHandlers = []
61
70
 
62
71
  this.on('error', (err, res) => {
@@ -78,7 +87,7 @@ class Robot {
78
87
  //
79
88
  // Returns nothing.
80
89
  listen (matcher, options, callback) {
81
- this.listeners.push(new Listener.Listener(this, matcher, options, callback))
90
+ this.listeners.push(new Listener(this, matcher, options, callback))
82
91
  }
83
92
 
84
93
  // Public: Adds a Listener that attempts to match incoming messages based on
@@ -91,7 +100,7 @@ class Robot {
91
100
  //
92
101
  // Returns nothing.
93
102
  hear (regex, options, callback) {
94
- this.listeners.push(new Listener.TextListener(this, regex, options, callback))
103
+ this.listeners.push(new TextListener(this, regex, options, callback))
95
104
  }
96
105
 
97
106
  // Public: Adds a Listener that attempts to match incoming messages directed
@@ -329,7 +338,7 @@ class Robot {
329
338
  }
330
339
 
331
340
  async loadjs (filePath) {
332
- const script = require(filePath)
341
+ const script = (await import(filePath)).default
333
342
  if (typeof script === 'function') {
334
343
  script(this)
335
344
  } else {
@@ -382,15 +391,19 @@ class Robot {
382
391
  // packages - An Array of packages containing hubot scripts to load.
383
392
  //
384
393
  // Returns nothing.
385
- loadExternalScripts (packages) {
394
+ async loadExternalScripts (packages) {
386
395
  this.logger.debug('Loading external-scripts from npm packages')
387
396
 
388
397
  try {
389
398
  if (Array.isArray(packages)) {
390
- return packages.forEach(pkg => require(pkg)(this))
399
+ for await (const pkg of packages) {
400
+ (await import(pkg)).default(this)
401
+ }
402
+ return
403
+ }
404
+ for await (const key of Object.keys(packages)) {
405
+ (await import(key)).default(this, packages[key])
391
406
  }
392
-
393
- Object.keys(packages).forEach(key => require(key)(this, packages[key]))
394
407
  } catch (error) {
395
408
  this.logger.error(`Error loading scripts from npm package - ${error.stack}`)
396
409
  throw error
@@ -409,9 +422,9 @@ class Robot {
409
422
  const limit = process.env.EXPRESS_LIMIT || '100kb'
410
423
  const paramLimit = parseInt(process.env.EXPRESS_PARAMETER_LIMIT) || 1000
411
424
 
412
- const express = require('express')
413
- const basicAuth = require('express-basic-auth')
414
- const multipart = require('connect-multiparty')
425
+ const express = (await import('express')).default
426
+ const basicAuth = (await import('express-basic-auth')).default
427
+ const multipart = (await import('connect-multiparty')).default
415
428
 
416
429
  const app = express()
417
430
 
@@ -471,19 +484,23 @@ class Robot {
471
484
  //
472
485
  // Returns nothing.
473
486
  async loadAdapter (adapterPath = null) {
487
+ if (this.adapter) {
488
+ this.adapter = await this.adapter.use(this)
489
+ return
490
+ }
474
491
  this.logger.debug(`Loading adapter ${adapterPath ?? 'from npmjs:'} ${this.adapterName}`)
475
- const ext = path.extname(adapterPath ?? '') ?? '.js'
492
+ const ext = path.extname(adapterPath ?? '') ?? '.mjs'
476
493
  try {
477
494
  if (Array.from(HUBOT_DEFAULT_ADAPTERS).indexOf(this.adapterName) > -1) {
478
- this.adapter = this.requireAdapterFrom(path.resolve(path.join(__dirname, 'adapters', this.adapterName)))
495
+ this.adapter = await this.requireAdapterFrom(path.resolve(path.join(__dirname, 'adapters', `${this.adapterName}.mjs`)))
479
496
  } else if (['.js', '.cjs'].includes(ext)) {
480
- this.adapter = this.requireAdapterFrom(path.resolve(adapterPath))
497
+ this.adapter = await this.requireAdapterFrom(path.resolve(adapterPath))
481
498
  } else if (['.mjs'].includes(ext)) {
482
499
  this.adapter = await this.importAdapterFrom(pathToFileURL(path.resolve(adapterPath)).href)
483
500
  } else {
484
501
  const adapterPathInCurrentWorkingDirectory = this.adapterName
485
502
  try {
486
- this.adapter = this.requireAdapterFrom(adapterPathInCurrentWorkingDirectory)
503
+ this.adapter = await this.requireAdapterFrom(adapterPathInCurrentWorkingDirectory)
487
504
  } catch (err) {
488
505
  if (err.name === 'SyntaxError') {
489
506
  this.adapter = await this.importAdapterFrom(adapterPathInCurrentWorkingDirectory)
@@ -498,8 +515,8 @@ class Robot {
498
515
  }
499
516
  }
500
517
 
501
- requireAdapterFrom (adapaterPath) {
502
- return require(adapaterPath).use(this)
518
+ async requireAdapterFrom (adapaterPath) {
519
+ return await this.importAdapterFrom(adapaterPath)
503
520
  }
504
521
 
505
522
  async importAdapterFrom (adapterPath) {
@@ -515,12 +532,12 @@ class Robot {
515
532
 
516
533
  // Private: load help info from a loaded script.
517
534
  //
518
- // path - A String path to the file on disk.
535
+ // filePath - A String path to the file on disk.
519
536
  //
520
537
  // Returns nothing.
521
- parseHelp (path) {
538
+ parseHelp (filePath) {
522
539
  const scriptDocumentation = {}
523
- const body = fs.readFileSync(require.resolve(path), 'utf-8')
540
+ const body = fs.readFileSync(path.resolve(filePath), 'utf-8')
524
541
 
525
542
  const useStrictHeaderRegex = /^["']use strict['"];?\s+/
526
543
  const lines = body.replace(useStrictHeaderRegex, '').split(/(?:\n|\r\n|\r)/)
@@ -657,7 +674,7 @@ class Robot {
657
674
  //
658
675
  // Returns a String of the version number.
659
676
  parseVersion () {
660
- const pkg = require(path.join(__dirname, '..', 'package.json'))
677
+ const pkg = fs.readFileSync(path.join(__dirname, '..', 'package.json'))
661
678
  this.version = pkg.version
662
679
 
663
680
  return this.version
@@ -716,8 +733,6 @@ class Robot {
716
733
  }
717
734
  }
718
735
 
719
- module.exports = Robot
720
-
721
736
  function isCatchAllMessage (message) {
722
737
  return message instanceof Message.CatchAllMessage
723
738
  }
@@ -744,9 +759,7 @@ function removeCommentPrefix (line) {
744
759
  return line.replace(/^[#/]+\s*/, '')
745
760
  }
746
761
 
747
- function extend (obj/* , ...sources */) {
748
- const sources = [].slice.call(arguments, 1)
749
-
762
+ function extend (obj, ...sources) {
750
763
  sources.forEach((source) => {
751
764
  if (typeof source !== 'object') {
752
765
  return
@@ -759,3 +772,5 @@ function extend (obj/* , ...sources */) {
759
772
 
760
773
  return obj
761
774
  }
775
+
776
+ export default Robot
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const DataStoreUnavailable = require('./datastore').DataStoreUnavailable
3
+ import { DataStoreUnavailable } from './DataStore.mjs'
4
4
 
5
5
  class User {
6
6
  // Represents a participating user in the chat.
@@ -62,4 +62,4 @@ class User {
62
62
  }
63
63
  }
64
64
 
65
- module.exports = User
65
+ export default User
@@ -1,16 +1,9 @@
1
1
  'use strict'
2
2
 
3
- const HTTPS = require('https')
4
- const EventEmitter = require('events').EventEmitter
5
-
6
- const Adapter = require('../adapter')
7
-
8
- const Message = require('../message')
9
-
10
- const TextMessage = Message.TextMessage
11
- const EnterMessage = Message.EnterMessage
12
- const LeaveMessage = Message.LeaveMessage
13
- const TopicMessage = Message.TopicMessage
3
+ import HTTPS from 'node:https'
4
+ import EventEmitter from 'node:events'
5
+ import Adapter from '../Adapter.mjs'
6
+ import { TextMessage, EnterMessage, LeaveMessage, TopicMessage } from '../Message.mjs'
14
7
 
15
8
  class Campfire extends Adapter {
16
9
  send (envelope/* , ...strings */) {
@@ -157,8 +150,6 @@ class Campfire extends Adapter {
157
150
  }
158
151
  }
159
152
 
160
- exports.use = robot => new Campfire(robot)
161
-
162
153
  class CampfireStreaming extends EventEmitter {
163
154
  constructor (options, robot) {
164
155
  super()
@@ -392,3 +383,9 @@ class CampfireStreaming extends EventEmitter {
392
383
  return request.on('error', err => logger.error(`Campfire request error: ${err}`))
393
384
  }
394
385
  }
386
+
387
+ export default {
388
+ use (robot) {
389
+ return new Campfire(robot)
390
+ }
391
+ }
@@ -1,9 +1,9 @@
1
1
  'use strict'
2
2
 
3
- const fs = require('fs')
4
- const readline = require('node:readline')
5
- const Adapter = require('../adapter')
6
- const { TextMessage } = require('../message')
3
+ import fs from 'node:fs'
4
+ import readline from 'node:readline'
5
+ import Adapter from '../Adapter.mjs'
6
+ import { TextMessage } from '../Message.mjs'
7
7
 
8
8
  const historySize = process.env.HUBOT_SHELL_HISTSIZE != null ? parseInt(process.env.HUBOT_SHELL_HISTSIZE) : 1024
9
9
  const historyPath = '.hubot_history'
@@ -16,7 +16,7 @@ const completer = line => {
16
16
  }
17
17
  const showHelp = () => {
18
18
  console.log('usage:')
19
- console.log('\\q, exit - close shell and exit')
19
+ console.log('\\q, exit - close Shell and exit')
20
20
  console.log('\\?, help - show this help')
21
21
  console.log('\\c, clear - clear screen')
22
22
  }
@@ -112,4 +112,8 @@ class Shell extends Adapter {
112
112
 
113
113
  // Prevent output buffer "swallowing" every other character on OSX / Node version > 16.19.0.
114
114
  process.stdout._handle.setBlocking(false)
115
- exports.use = robot => new Shell(robot)
115
+ export default {
116
+ use (robot) {
117
+ return new Shell(robot)
118
+ }
119
+ }
@@ -1,6 +1,6 @@
1
1
  'use strict'
2
2
 
3
- const DataStore = require('../datastore.js').DataStore
3
+ import { DataStore } from '../DataStore.mjs'
4
4
 
5
5
  class InMemoryDataStore extends DataStore {
6
6
  constructor (robot) {
@@ -20,4 +20,4 @@ class InMemoryDataStore extends DataStore {
20
20
  }
21
21
  }
22
22
 
23
- module.exports = InMemoryDataStore
23
+ export default InMemoryDataStore
package/index.js DELETED
@@ -1,31 +0,0 @@
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
- }