➕ Add XML parser
This commit is contained in:
parent
2d55189248
commit
f01a880ae6
4 changed files with 23 additions and 4 deletions
13
package-lock.json
generated
13
package-lock.json
generated
|
@ -8,6 +8,19 @@
|
||||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.3.4.tgz",
|
"resolved": "https://registry.npmjs.org/@types/node/-/node-10.3.4.tgz",
|
||||||
"integrity": "sha512-YMLlzdeNnAyLrQew39IFRkMacAR5BqKGIEei9ZjdHsIZtv+ZWKYTu1i7QJhetxQ9ReXx8w5f+cixdHZG3zgMQA==",
|
"integrity": "sha512-YMLlzdeNnAyLrQew39IFRkMacAR5BqKGIEei9ZjdHsIZtv+ZWKYTu1i7QJhetxQ9ReXx8w5f+cixdHZG3zgMQA==",
|
||||||
"dev": true
|
"dev": true
|
||||||
|
},
|
||||||
|
"sax": {
|
||||||
|
"version": "1.2.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/sax/-/sax-1.2.4.tgz",
|
||||||
|
"integrity": "sha512-NqVDv9TpANUjFm0N8uM5GxL36UgKi9/atZw+x7YFnQ8ckwFGKrl4xX4yWtrey3UJm5nP1kUbnYgLopqWNSRhWw=="
|
||||||
|
},
|
||||||
|
"xml-js": {
|
||||||
|
"version": "1.6.4",
|
||||||
|
"resolved": "https://registry.npmjs.org/xml-js/-/xml-js-1.6.4.tgz",
|
||||||
|
"integrity": "sha512-ZJ4DPgx97LzSdZ0NAbd0J5gWeSgWTpL2hIH1j1bOmk6QMyppee0S+vQAv/H+oYY1923kck5msPWOuSs0BDUh/w==",
|
||||||
|
"requires": {
|
||||||
|
"sax": "^1.2.4"
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,5 +7,8 @@
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/node": "^10.3.4"
|
"@types/node": "^10.3.4"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"xml-js": "^1.6.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,8 +4,8 @@ import getSolidpkg from './ssn/getSolidpkg';
|
||||||
(async () => {
|
(async () => {
|
||||||
//----- PATCHMANIFEST -----
|
//----- PATCHMANIFEST -----
|
||||||
//.patchmanifest files contain a single XML file called "manifest.xml"
|
//.patchmanifest files contain a single XML file called "manifest.xml"
|
||||||
//const patchmanifestXml = await getPatchmanifest('assets_swtor_de_de');
|
const patchmanifestJson = await getPatchmanifest('assets_swtor_de_de');
|
||||||
//console.log(patchmanifestXml);
|
console.log(patchmanifestJson);
|
||||||
|
|
||||||
//----- SOLIDPKG -----
|
//----- SOLIDPKG -----
|
||||||
//.solidpkg files contain a single Bencode file called "metafile.solid"
|
//.solidpkg files contain a single Bencode file called "metafile.solid"
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { TextDecoder } from 'util';
|
import { TextDecoder } from 'util';
|
||||||
|
import * as xmlJs from 'xml-js';
|
||||||
import getUrlContents from '../cdn/getUrlContents';
|
import getUrlContents from '../cdn/getUrlContents';
|
||||||
import { Product } from '../interfaces/ISettings';
|
import { Product } from '../interfaces/ISettings';
|
||||||
import verifyProductName from '../ssn/verifyProductName';
|
import verifyProductName from '../ssn/verifyProductName';
|
||||||
|
@ -7,7 +8,7 @@ import readSsnFile from './readSsnFile';
|
||||||
|
|
||||||
const Decoder = new TextDecoder('utf-8');
|
const Decoder = new TextDecoder('utf-8');
|
||||||
|
|
||||||
export default async function getPatchmanifest(product: Product): Promise<string> {
|
export default async function getPatchmanifest(product: Product): Promise<any> {
|
||||||
//Verify function arguments
|
//Verify function arguments
|
||||||
if (!verifyProductName(product)) {
|
if (!verifyProductName(product)) {
|
||||||
throw new Error(`"${product}" is not a valid product.`);
|
throw new Error(`"${product}" is not a valid product.`);
|
||||||
|
@ -32,5 +33,7 @@ export default async function getPatchmanifest(product: Product): Promise<string
|
||||||
const patchmanifestFile = await extractFile(firstFile, [new DataView(ssnFile)]);
|
const patchmanifestFile = await extractFile(firstFile, [new DataView(ssnFile)]);
|
||||||
const patchmanifestXml = Decoder.decode(patchmanifestFile);
|
const patchmanifestXml = Decoder.decode(patchmanifestFile);
|
||||||
|
|
||||||
return patchmanifestXml;
|
const patchManifestJson = xmlJs.xml2js(patchmanifestXml);
|
||||||
|
|
||||||
|
return patchManifestJson;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue