From f01a880ae692a7a5948307ac045f4e337fd4fa83 Mon Sep 17 00:00:00 2001 From: C-3PO Date: Sat, 23 Jun 2018 20:20:03 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9E=95=20Add=20XML=20parser?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- package-lock.json | 13 +++++++++++++ package.json | 3 +++ src/installPatch.ts | 4 ++-- src/ssn/getPatchmanifest.ts | 7 +++++-- 4 files changed, 23 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index eb5cfdf..7259d6e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,6 +8,19 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-10.3.4.tgz", "integrity": "sha512-YMLlzdeNnAyLrQew39IFRkMacAR5BqKGIEei9ZjdHsIZtv+ZWKYTu1i7QJhetxQ9ReXx8w5f+cixdHZG3zgMQA==", "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" + } } } } diff --git a/package.json b/package.json index ca4cf2a..bb89899 100644 --- a/package.json +++ b/package.json @@ -7,5 +7,8 @@ }, "devDependencies": { "@types/node": "^10.3.4" + }, + "dependencies": { + "xml-js": "^1.6.4" } } diff --git a/src/installPatch.ts b/src/installPatch.ts index bb1e084..7e7a41a 100644 --- a/src/installPatch.ts +++ b/src/installPatch.ts @@ -4,8 +4,8 @@ import getSolidpkg from './ssn/getSolidpkg'; (async () => { //----- PATCHMANIFEST ----- //.patchmanifest files contain a single XML file called "manifest.xml" - //const patchmanifestXml = await getPatchmanifest('assets_swtor_de_de'); - //console.log(patchmanifestXml); + const patchmanifestJson = await getPatchmanifest('assets_swtor_de_de'); + console.log(patchmanifestJson); //----- SOLIDPKG ----- //.solidpkg files contain a single Bencode file called "metafile.solid" diff --git a/src/ssn/getPatchmanifest.ts b/src/ssn/getPatchmanifest.ts index d0c231e..1786da8 100644 --- a/src/ssn/getPatchmanifest.ts +++ b/src/ssn/getPatchmanifest.ts @@ -1,4 +1,5 @@ import { TextDecoder } from 'util'; +import * as xmlJs from 'xml-js'; import getUrlContents from '../cdn/getUrlContents'; import { Product } from '../interfaces/ISettings'; import verifyProductName from '../ssn/verifyProductName'; @@ -7,7 +8,7 @@ import readSsnFile from './readSsnFile'; const Decoder = new TextDecoder('utf-8'); -export default async function getPatchmanifest(product: Product): Promise { +export default async function getPatchmanifest(product: Product): Promise { //Verify function arguments if (!verifyProductName(product)) { throw new Error(`"${product}" is not a valid product.`); @@ -32,5 +33,7 @@ export default async function getPatchmanifest(product: Product): Promise