Created
July 7, 2017 02:06
-
-
Save wffurr/6797a5853e7cce4b66e51ce0cba25a4e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var fs = require('fs'); | |
var path = require('path'); | |
var yaml = require('js-yaml'); | |
var printUsage = function() { | |
console.log('Usage: node import-sde.js <path-to-sde>'); | |
process.exit(1); | |
}; | |
var sde_path = process.argv[2]; | |
if (!sde_path || | |
!fs.statSync(sde_path).isDirectory() || | |
!fs.statSync(path.join(sde_path, 'fsd')).isDirectory()) { | |
printUsage(); | |
} | |
var files = fs.readdirSync(path.join(sde_path, 'fsd')); | |
if (!'blueprints.yaml' in files || | |
!'categoryIDs.yaml' in files || | |
!'groupIDs.yaml' in files || | |
!'typeIDs.yaml' in files) { | |
printUsage(); | |
} | |
fs.createReadStream(path.join(sde_path, 'fsd', 'blueprints.yaml')).pipe(fs.createWriteStream('blueprints.yaml')); | |
var strip = function(sde_yaml) { | |
for (var val in sde_yaml) { | |
if (!sde_yaml.hasOwnProperty(val)) continue; | |
if (!sde_yaml[val].hasOwnProperty('name')) continue; | |
var name = sde_yaml[val].name.en; | |
delete sde_yaml[val].name; | |
delete sde_yaml[val].description; | |
delete sde_yaml[val].traits; | |
delete sde_yaml[val].masteries; | |
sde_yaml[val].name = name || ''; | |
} | |
return sde_yaml; | |
}; | |
var categoryids = yaml.safeLoad(fs.readFileSync(path.join(sde_path, 'fsd', 'categoryIDs.yaml'), 'utf8')); | |
fs.writeFileSync('categoryIDs.yaml', yaml.safeDump(strip(categoryids))); | |
var groupids = yaml.safeLoad(fs.readFileSync(path.join(sde_path, 'fsd', 'groupIDs.yaml'), 'utf8')); | |
fs.writeFileSync('groupIDs.yaml', yaml.safeDump(strip(groupids))); | |
var typeids = yaml.safeLoad(fs.readFileSync(path.join(sde_path, 'fsd', 'typeIDs.yaml'), 'utf8')); | |
fs.writeFileSync('typeIDs.yaml', yaml.safeDump(strip(typeids))); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment