Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Print warning for loading deprecated hubot-scripts.json #970

Merged
merged 6 commits into from
May 6, 2016
Merged
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
35 changes: 34 additions & 1 deletion bin/hubot
Original file line number Diff line number Diff line change
Expand Up @@ -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) ->
Expand Down