-
Couldn't load subscription status.
- Fork 3.7k
CoffeeScript 🔜 JavaScript #1347
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
dda9d72
ab527de
7939b8f
eb9a20b
3b2ec09
0c4debb
9987f07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 | ||
| - "7" | ||
| - "8" | ||
| - "6" | ||
| - "5" | ||
| - "4" | ||
| - "0.12" | ||
| - "0.10" | ||
| notifications: | ||
| email: false | ||
| sudo: false | ||
| 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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 Also, should we print a deprecation warning that coffee script will not be supported in the major release that follows this one? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don’t think 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' | ||
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.ymlfile. I think that’d be the perfect way