Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
language: node_js
node_js:
- "node" # latest stable Node.js release
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to keep this in so we're always running against the latest release? Or are you concerned it would lead to unexpected failures when new node releases are put out and we should make sure we're being explicit about which versions are supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah it would lead to unexpected failures, node major versions are still breaking versions. We are experimenting with Greenkeeper sending PRs to update the these versions, so as soon as version 9 comes out it will send a PR updating the .travis.yml file. I think that’d be the perfect way

- "7"
- "8"
- "6"
- "5"
- "4"
- "0.12"
- "0.10"
notifications:
email: false
sudo: false
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## [v2.19.0](https://github.com/github/hubot/tree/v3.0.0) (2017-06-09)
[Full Changelog](https://github.com/github/hubot/compare/v2.19.0...v3.0.0)

### Breaking Changes

- node@0.10 and node@0.12 are no longer supported
- Deep requires like `require('hubot/src/adapter')` are no longer support, use `require('hubot').Adapter` instead.
- `Middleware.ticker()` has been removed. Use `process.nextTick()` instead

### Features

- We now export es2015 `class` declarations of all Hubot classes at `require('hubot/es2015')`

## [v2.19.0](https://github.com/github/hubot/tree/v2.19.0) (2016-05-0-6)
[Full Changelog](https://github.com/github/hubot/compare/v2.18.0...v2.19.0)

Expand Down
171 changes: 6 additions & 165 deletions bin/hubot
Original file line number Diff line number Diff line change
@@ -1,168 +1,9 @@
#!/usr/bin/env coffee
# vim:ft=coffee ts=2 sw=2 et :
# -*- mode:coffee -*-

Hubot = require '..'
# While all other files have been converted to JavaScript via https://github.com/github/hubot/pull/1347,
# we left the `bin/hubot` file to remain in CoffeeScript in order prevent
# breaking existing 3rd party adapters of which some are still written in
# CoffeeScript themselves. We will depracate and eventually remove this file
# in a future version of hubot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I understand this. As long as it still includes a require('coffee-script'), shouldn't it be able to load JavaScript?

Also, should we print a deprecation warning that coffee script will not be supported in the major release that follows this one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don’t think require('coffee-script') will be enough, I'll have to investigate it. If you don’t mind I’d make a follow up PR to change it later if it works.

Regarding the deprecation warning I’m not yet sure when we drop CoffeeScript support officially, but we can add a deprecation warning in a patch release, too, so we don’t keep that PR waiting


Fs = require 'fs'
OptParse = require 'optparse'
Path = require 'path'

Switches = [
[ "-a", "--adapter ADAPTER", "The Adapter to use" ],
[ "-c", "--create PATH", "Create a deployable hubot" ],
[ "-d", "--disable-httpd", "Disable the HTTP server" ],
[ "-h", "--help", "Display the help information" ],
[ "-l", "--alias ALIAS", "Enable replacing the robot's name with alias" ],
[ "-n", "--name NAME", "The name of the robot in chat" ],
[ "-r", "--require PATH", "Alternative scripts path" ],
[ "-t", "--config-check", "Test hubot's config to make sure it won't fail at startup"]
[ "-v", "--version", "Displays the version of hubot installed" ]
]

Options =
adapter: process.env.HUBOT_ADAPTER or "shell"
alias: process.env.HUBOT_ALIAS or false
create: process.env.HUBOT_CREATE or false
enableHttpd: process.env.HUBOT_HTTPD or true
scripts: process.env.HUBOT_SCRIPTS or []
name: process.env.HUBOT_NAME or "Hubot"
path: process.env.HUBOT_PATH or "."
configCheck: false

Parser = new OptParse.OptionParser(Switches)
Parser.banner = "Usage hubot [options]"

Parser.on "adapter", (opt, value) ->
Options.adapter = value

Parser.on "create", (opt, value) ->
Options.path = value
Options.create = true

Parser.on "disable-httpd", (opt) ->
Options.enableHttpd = false

Parser.on "help", (opt, value) ->
console.log Parser.toString()
process.exit 0

Parser.on "alias", (opt, value) ->
value or= '/'
Options.alias = value

Parser.on "name", (opt, value) ->
Options.name = value

Parser.on "require", (opt, value) ->
Options.scripts.push(value)

Parser.on "config-check", (opt) ->
Options.configCheck = true

Parser.on "version", (opt, value) ->
Options.version = true

Parser.on (opt, value) ->
console.warn "Unknown option: #{opt}"

Parser.parse process.argv

unless process.platform is "win32"
process.on 'SIGTERM', ->
process.exit 0

if Options.create
console.error "'hubot --create' is deprecated. Use the yeoman generator instead:"
console.error " npm install -g yo generator-hubot"
console.error " mkdir -p #{Options.path}"
console.error " cd #{Options.path}"
console.error " yo hubot"
console.error "See https://github.com/github/hubot/blob/master/docs/index.md for more details on getting started."
process.exit 1

else
robot = Hubot.loadBot undefined, Options.adapter, Options.enableHttpd, Options.name, Options.alias

if Options.version
console.log robot.version
process.exit 0

loadScripts = ->
scriptsPath = Path.resolve ".", "scripts"
robot.load scriptsPath

scriptsPath = Path.resolve ".", "src", "scripts"
robot.load scriptsPath

hubotScripts = Path.resolve ".", "hubot-scripts.json"
if Fs.existsSync(hubotScripts)
data = Fs.readFileSync(hubotScripts)
if data.length > 0
try
scripts = JSON.parse data
scriptsPath = Path.resolve "node_modules", "hubot-scripts", "src", "scripts"
robot.loadHubotScripts scriptsPath, scripts
catch err
robot.logger.error "Error parsing JSON data from hubot-scripts.json: #{err}"
process.exit(1)

hubotScriptsWarning = "Loading scripts from hubot-scripts.json is deprecated and " +
"will be removed in 3.0 (https://github.com/github/hubot-scripts/issues/1113) " +
"in favor of packages for each script.\n\n"

if scripts.length is 0
hubotScriptsWarning += "Your hubot-scripts.json is empty, so you just need to remove it."
else
hubotScriptsReplacements = Path.resolve "node_modules", "hubot-scripts", "replacements.json"

if Fs.existsSync(hubotScriptsReplacements)
hubotScriptsWarning += "The following scripts have known replacements. Follow the link for installation instructions, then remove it from hubot-scripts.json:\n"

replacementsData = Fs.readFileSync(hubotScriptsReplacements)
replacements = JSON.parse(replacementsData)
scriptsWithoutReplacements = []
for script in scripts
replacement = replacements[script]
if replacement
hubotScriptsWarning += "* #{script}: #{replacement}\n"
else
scriptsWithoutReplacements.push(script)
hubotScriptsWarning += "\n"

if scriptsWithoutReplacements.length > 0
hubotScriptsWarning += "The following scripts don't have (known) replacements. You can try searching https://www.npmjs.com/ or http://github.com/search or your favorite search engine. You can copy the script into your local scripts directory, or consider creating a new package to maintain yourself. If you find a replacement or create a package yourself, please post on https://github.com/github/hubot-scripts/issues/1641:\n"
hubotScriptsWarning += "* #{script}\n" for script in scriptsWithoutReplacements

hubotScriptsWarning += "\nYou an also try updating hubot-scripts to get the latest list of replacements: npm install --save hubot-scripts@latest"
else
hubotScriptsWarning += "To get a list of recommended replacements, update your hubot-scripts: npm install --save hubot-scripts@latest"

robot.logger.warning hubotScriptsWarning

externalScripts = Path.resolve ".", "external-scripts.json"
if Fs.existsSync(externalScripts)
Fs.readFile externalScripts, (err, data) ->
if data.length > 0
try
scripts = JSON.parse data
catch err
console.error "Error parsing JSON data from external-scripts.json: #{err}"
process.exit(1)
robot.loadExternalScripts scripts

for path in Options.scripts
if path[0] == '/'
scriptsPath = path
else
scriptsPath = Path.resolve ".", path
robot.load scriptsPath

if Options.configCheck
loadScripts()
console.log "OK"
process.exit 0

robot.adapter.once 'connected', loadScripts

robot.run()
require './hubot.js'
Loading