Skip to content

Instantly share code, notes, and snippets.

@arieh
Last active June 11, 2018 21:01
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save arieh/4bb049d62fce4058e1687b0b66f17f1a to your computer and use it in GitHub Desktop.
Save arieh/4bb049d62fce4058e1687b0b66f17f1a to your computer and use it in GitHub Desktop.
Check for possible 8.0 update issues
/*
This file will traverse through your folders and will check if a file has possible issues with 8.0 update
usage:
node wow_updater.js -d [folder path]
*/
const fs = require('fs');
const path = require('path');
const rule_map ={
GetActiveArtifactByRace : "#5 (spell description) - use SpellMixin",
GetArtifactInfoByRace : "#5 (spell description) - use SpellMixin",
GetRecipeDescription : "#1(spell description) - use SpellMixin",
GetSelectedArtifactInfo : "#5 (spell description) - use SpellMixin",
GetSpellBookItemName : "#2 (spell name subtext) - use SpellMixin",
GetSpellDescription : "#1 (spell description) - use SpellMixin",
GetTrainerServiceAbilityReq : "#1(spell name subtext) - use SpellMixin",
GetTrainerServiceDescription : "#1 (spell description) - use SpellMixin",
GetSpellInfo : "second parameter used to return Spell.nameSubtext -- now returns nil.",
GetTrainerServiceInfo: "dropped second parameter (nameSubtext).",
GetShapeshiftFormInfo: "dropped second parameter (name).",
GetMacroSpell : "dropped first two parameters (name, and nameSubtext).",
GetPetActionInfo : "dropped second parameter (nameSubtext).",
GetPossessInfo : "second parameter changed from spell name to spell ID.",
CancelUnitBuff : "no longer supports canceling by spell name.",
UnitBuff : "dropped second parameter (nameSubtext). Also, no longer supports querying by spell name.",
UnitDebuff : "dropped second parameter (nameSubtext). Also, no longer supports querying by spell name.",
UnitAura : "dropped second parameter (nameSubtext). Also, no longer supports querying by spell name.",
UnitCastingInfo : "dropped second parameter (nameSubtext).",
UnitChannelInfo : "dropped second parameter (nameSubtext).",
"GameTooltip:GetSpell" : "dropped second parameter (nameSubtext).",
GetAuraInfo : "no longer supports querying by spell name.",
GetItemSpell : "dropped second parameter (nameSubtext).",
GetSpellLink : "no longer returns trade skill link as second parameter (see GetSpellTradeSkillLink below).",
FindSpellOverrideNameByName : "Removed",
FindBaseSpellNameByName : "Removed",
SearchGuildRecipes : "Removed",
IT_SPELLCAST_SUCCEEDED : "no longer provide spell name and rank.",
UNIT_SPELLCAST_FAILED_QUIET : "no longer provide spell name and rank.",
UNIT_SPELLCAST_INTERRUPTED : "no longer provide spell name and rank.",
UNIT_SPELLCAST_START : "no longer provide spell name and rank.",
UNIT_SPELLCAST_FAILED : "no longer provide spell name and rank.",
UNIT_SPELLCAST_STOP : "no longer provide spell name and rank.",
UNIT_SPELLCAST_DELAYED : "no longer provide spell name and rank.",
UNIT_SPELLCAST_CHANNEL_START : "no longer provide spell name and rank.",
UNIT_SPELLCAST_CHANNEL_UPDATE : "no longer provide spell name and rank.",
UNIT_SPELLCAST_CHANNEL_STOP : "no longer provide spell name and rank.",
COMBAT_LOG_EVENT : "No longer provides event details, use CombatLogGetCurrentEventInfo",
COMBAT_LOG_EVENT_UNFILTERED : "No longer provides event details, use CombatLogGetCurrentEventInfo",
SendAddonMessage : "Removed - use the new C_ChatInfo namespace",
RegisterAddonMessagePrefix : "Removed - use the new C_ChatInfo namespace",
IsAddonMessagePrefixRegistered : "Removed - use the new C_ChatInfo namespace",
GetRegisteredAddonMessagePrefixes : "Removed - use the new C_ChatInfo namespace",
UNIT_POWER : "Changed to UNIT_POWER_UPDATED",
GetCurrentMapAreaID : "has been removed. Use C_Map.GetBestMapForUnit(\"player\") to get the current uiMapID for the player or WorldMapFrame:GetMapID() to get the uiMapID map currently displayed in the World Map Frame UI.",
GetPlayerMapPosition : "has been removed. Use C_Map.GetPlayerMapPosition(uiMapID, unitToken) to get the position of the unit (only works for the player and party members).",
EJ_GetCurrentInstance : "has been removed, use EJ_GetInstanceForMap(C_Map.GetBestMapForUnit(\"player\")) instead to get the current instance ID.",
GLYPH_ADDED: "Removed",
GLYPH_REMOVED: "Removed",
GLYPH_UPDATED: "Removed"
};
const keys = Object.keys(rule_map);
const start_wrapper = '(\\W|^)(';
const end_wrapper = ')(\\W|$)';
const regex = new RegExp(`${start_wrapper}${keys.join(`${end_wrapper}|${start_wrapper}`)}${end_wrapper}`,'g');
let is_folder = false;
let filename = "";
let files;
processArgs();
if (!is_folder) {
checkFiles([path.resolve(__dirname, filename)]);
} else {
filewalker(path.resolve(__dirname, filename), (e, files)=>{
checkFiles(files);
});
}
function checkFiles(arr){
const file = arr.shift();
if (!file) return;
checkFile(file, ()=>{
checkFiles(arr);
});
}
function checkFile(path, done){
if (path.indexOf('.lua')==-1) return done();
fs.readFile(path, (e, content)=>{
if (e) {
return done();
}
const lines = ("" + content).split('\n');
const errors = []
lines.forEach((line, i)=>{
const match = line.match(regex);
if (!match) return;
match.forEach((key)=>{
key = key.replace(/\W/g,"");
errors.push(`line#${i+1}: ${key}: ${rule_map[key]}\n`);
});
});
if (errors.length) {
console.log(path,'\n========');
errors.forEach(error=>console.log(error))
}
done();
});
}
function processArgs(){
let args = [...process.argv];
let first;
while (first = args[0]){
args.shift();
if (first == __filename) {
break;
}
}
if (args[0] == "-d") {
is_folder = true;
args.shift();
}
filename = args[0];
}
/**
* Explores recursively a directory and returns all the filepaths and folderpaths in the callback.
*
* @see http://stackoverflow.com/a/5827895/4241030
* @param {String} dir
* @param {Function} done
*/
function filewalker(dir, done) {
let results = [];
fs.readdir(dir, function(err, list) {
if (err) return done(err);
var pending = list.length;
if (!pending) return done(null, results);
list.forEach(function(file){
file = path.resolve(dir, file);
fs.stat(file, function(err, stat){
// If directory, execute a recursive call
if (stat && stat.isDirectory()) {
// Add directory to array [comment if you need to remove the directories from the array]
results.push(file);
filewalker(file, function(err, res){
results = results.concat(res);
if (!--pending) done(null, results);
});
} else {
results.push(file);
if (!--pending) done(null, results);
}
});
});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment