diff --git a/bin/hubot b/bin/hubot index 9e355b88b..c55241ed7 100755 --- a/bin/hubot +++ b/bin/hubot @@ -104,9 +104,42 @@ else scriptsPath = Path.resolve "node_modules", "hubot-scripts", "src", "scripts" robot.loadHubotScripts scriptsPath, scripts catch err - console.error "Error parsing JSON data from hubot-scripts.json: #{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) ->