Skip to content
This repository was archived by the owner on Jun 8, 2023. It is now read-only.

Commit 5fda766

Browse files
Keep track of hubot-scripts replacements in replacement.json, and add helper for deprecating a script.
1 parent fc269a5 commit 5fda766

File tree

3 files changed

+53
-2
lines changed

3 files changed

+53
-2
lines changed

replacements.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"9gag.coffee": "https://github.com/luijose/hubot-9gag",
3+
"ambush": "https://github.com/hubot-scripts/hubot-ambush",
4+
"asana.coffee": "https://github.com/hubot-scripts/hubot-asana",
5+
"auth": "https://github.com/hubot-scripts/hubot-auth",
6+
"darksky.coffee": "https://github.com/hubot-scripts/hubot-darksky",
7+
"factoids.coffee": "https://github.com/hubot-scripts/hubot-factoids",
8+
"gitlab.coffee": "https://github.com/spruce/hubot-gitlab-hooks",
9+
"google.coffee": "https://github.com/mnpk/hubot-google",
10+
"isup.coffee": "https://github.com/pric/hubot-isup",
11+
"jenkins.coffee": "https://github.com/balbeko/hubot-jenkins",
12+
"jira-issues.coffee": "https://github.com/rustedgrail/hubot-jira",
13+
"karma.coffee": "https://github.com/ajacksified/hubot-plusplus",
14+
"meme_captain.coffee": "https://github.com/cycomachead/hubot-meme",
15+
"pagerduty": "https://github.com/hubot-scripts/hubot-pager-me",
16+
"plusplus": "https://github.com/ajacksified/hubot-plusplus",
17+
"resumator.coffee": "https://github.com/ChrisMissal/hubot-resumator",
18+
"tell": "https://github.com/hubot-scripts/hubot-tell",
19+
"wolfram.coffee": "https://github.com/notpeter/hubot-wolfram",
20+
"xkcd.coffee": "https://www.npmjs.com/package/hubot-xkcd",
21+
"youtube-info": "https://github.com/ClaudeBot/hubot-youtube-info"
22+
}

src/hubot-scripts.coffee

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
Path = require 'path'
2+
Fs = require 'fs'
3+
4+
HubotScripts = {}
5+
6+
replacementsPath = Path.resolve(__dirname, "..", "replacements.json")
7+
8+
if Fs.existsSync(replacementsPath)
9+
data = Fs.readFileSync(replacementsPath)
10+
if data.length > 0
11+
try
12+
replacements = JSON.parse data
13+
catch err
14+
console.error "Error parsing JSON data from hubot-scripts's replacements.json: #{err}"
15+
process.exit(1)
16+
17+
HubotScripts.replacements = replacements ?= {}
18+
19+
HubotScripts.deprecatedScriptsUsed = deprecatedScriptsUsed = []
20+
HubotScripts.deprecate = (robot, filename) ->
21+
filename = Path.basename(filename)
22+
23+
replacement = replacements[filename]
24+
if replacement
25+
robot.logger.warning "#{filename} has moved to its own package. Remove it from your hubot-scripts.json and see #{replacement} for how to install the new version"
26+
deprecatedScriptsUsed.push(filename)
27+
28+
module.exports = HubotScripts

src/scripts/9gag.coffee

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,13 @@
1717
# Contributors:
1818
# dedeibel (gif support)
1919

20+
Path = require("path")
21+
HubotScripts = require(Path.resolve(__dirname, "..", "hubot-scripts"))
2022
Select = require( "soupselect" ).select
2123
HTMLParser = require "htmlparser"
2224

2325
module.exports = (robot)->
24-
robot.logger.warning "9gag.coffee has moved from hubot-scripts to its own package. See https://github.com/luijose/hubot-9gag installation instructions"
26+
HubotScripts.deprecate(robot, __filename)
2527

2628
robot.respond /9gag( me)?/i, (message)->
2729
send_meme message, false, (title, src)->
@@ -81,4 +83,3 @@ escape_html_characters = (text)->
8183
for r in replacements
8284
text = text.replace r[0], r[1]
8385
return text
84-

0 commit comments

Comments
 (0)