Fixes around JSON parsing and XML encoding name values
This commit is contained in:
Родитель
7b73a3595d
Коммит
de3a7ea305
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"version": "0.0.6",
|
||||
"version": "0.0.9",
|
||||
"name": "hwa-cli",
|
||||
"title": "HWA Deployment Command-Line interface",
|
||||
"description": "Command-Line interface for deploying HWAs locally and remotely via HWA-Server.",
|
||||
|
@ -34,4 +34,4 @@
|
|||
"optionalDependencies": {
|
||||
"appx-tools": "^0.0.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,15 @@
|
|||
<TypeScriptCompile Include="..\..\src\cli.ts">
|
||||
<Link>src\cli.ts</Link>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="..\..\src\cloudAppx.ts">
|
||||
<Link>src\cloudAppx.ts</Link>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="..\..\src\crxConverter.ts">
|
||||
<Link>src\crxConverter.ts</Link>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="..\..\src\webConverter.ts">
|
||||
<Link>src\webConverter.ts</Link>
|
||||
</TypeScriptCompile>
|
||||
<TypeScriptCompile Include="..\..\tests\adapterTests.ts">
|
||||
<Link>tests\adapterTests.ts</Link>
|
||||
</TypeScriptCompile>
|
||||
|
@ -42,6 +51,33 @@
|
|||
<Content Include="..\..\main.js">
|
||||
<Link>main.js</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\templates\AppxManifest\AppxManifest.xml">
|
||||
<Link>templates\AppxManifest\AppxManifest.xml</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\templates\w3c-AppxManifest-template.xml">
|
||||
<Link>templates\w3c-AppxManifest-template.xml</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="..\..\templates\rdConfig.rdp">
|
||||
<Link>templates\rdConfig.rdp</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="..\..\docs\connectionError">
|
||||
<Link>docs\connectionError</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\docs\fileNotSupported">
|
||||
<Link>docs\fileNotSupported</Link>
|
||||
</Content>
|
||||
<Content Include="..\..\docs\usage">
|
||||
<Link>docs\usage</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="..\..\package.json">
|
||||
<Link>package.json</Link>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<VisualStudioVersion Condition="'$(VisualStudioVersion)' == ''">12.0</VisualStudioVersion>
|
||||
|
|
|
@ -35,17 +35,19 @@ export function convert(src: string, dest: string) {
|
|||
extractCrx(src, dest);
|
||||
|
||||
// Convert manifest
|
||||
var chromeOSManifest = <webConverter.IChromeOSManifest>JSON.parse(fs.readFileSync(p.join(dest, "manifest.json"), "utf8").toString());
|
||||
var chromeOSManifest = <webConverter.IChromeOSManifest>JSON.parse(sanitizeJSONString(fs.readFileSync(p.join(dest, "manifest.json"), "utf8")));
|
||||
|
||||
var w3cManifest = webConverter.chromeToW3CManifest(chromeOSManifest, (locale, varName) => {
|
||||
// Note: variable name is not case sensitive
|
||||
varName = varName.toLowerCase();
|
||||
var locResPath = p.join(dest, "_locales", locale, "messages.json");
|
||||
if (fs.existsSync(locResPath)) {
|
||||
var msgs = JSON.parse(fs.readFileSync(locResPath, "utf8"));
|
||||
// We've encountered a bunch of malformed JSON so we need to trim them, then replace all newline characters with a space
|
||||
var msgs = JSON.parse(sanitizeJSONString(fs.readFileSync(locResPath, "utf8")));
|
||||
for (var key in msgs) {
|
||||
if (key.toLowerCase() === varName) {
|
||||
return msgs[key].message;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
@ -93,7 +95,6 @@ export function extractCrx(src: string, dest: string) {
|
|||
if (!fs.existsSync(dest)) {
|
||||
fs.mkdirSync(dest);
|
||||
}
|
||||
|
||||
var zipPath = p.join(dest, guid.raw() + ".zip");
|
||||
|
||||
// Read crx file
|
||||
|
@ -116,4 +117,8 @@ export function extractCrx(src: string, dest: string) {
|
|||
// Extract zip and cleanup
|
||||
new admzip(zipPath).extractAllTo(dest);
|
||||
fs.unlinkSync(zipPath);
|
||||
}
|
||||
|
||||
function sanitizeJSONString(str: string) {
|
||||
return str.trim().replace(/\r/g, "").replace(/\n/g, "");
|
||||
}
|
|
@ -97,7 +97,6 @@ export function chromeToW3CManifest(chromeManifest: IChromeOSManifest, resolveVa
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Extract icons
|
||||
for (var size in chromeManifest.icons) {
|
||||
w3cManifest.icons.push({
|
||||
|
@ -192,13 +191,13 @@ export function w3CToAppxManifest(w3cManifest: IW3CManifest, appxManifestTemplat
|
|||
.replace(/{Version}/g, "1.0.0.0")
|
||||
.replace(/{PublisherIdentity}/g, appIdentity.publisherIdentity)
|
||||
.replace(/{PhoneProductId}/g, guid)
|
||||
.replace(/{AppDisplayName}/g, w3cManifest.short_name)
|
||||
.replace(/{AppDisplayName}/g, encodeXML(w3cManifest.short_name))
|
||||
.replace(/{PublisherDisplayName}/g, appIdentity.publisherDisplayName)
|
||||
.replace(/{LogoStore}/g, logoStore.src)
|
||||
.replace(/{Locale}/g, w3cManifest.lang)
|
||||
.replace(/{ApplicationId}/g, sanitizeName(w3cManifest.short_name))
|
||||
.replace(/{StartPage}/g, encodeXML(w3cManifest.start_url))
|
||||
.replace(/{AppDescription}/g, (<any>w3cManifest)["description"] || w3cManifest.name)
|
||||
.replace(/{AppDescription}/g, encodeXML((<any>w3cManifest)["description"] || w3cManifest.name))
|
||||
.replace(/{ThemeColor}/g, w3cManifest.theme_color)
|
||||
.replace(/{LogoLarge}/g, logoLarge.src)
|
||||
.replace(/{LogoSmall}/g, logoSmall.src)
|
||||
|
|
|
@ -23,8 +23,6 @@
|
|||
<uap:Rule Type="include" WindowsRuntimeAccess="none" Match="https://*.google.com/" />
|
||||
<uap:Rule Type="include" WindowsRuntimeAccess="none" Match="https://*.live.com/" />
|
||||
<uap:Rule Type="include" WindowsRuntimeAccess="none" Match="https://*.youtube.com/" />
|
||||
<uap:Rule Type="include" WindowsRuntimeAccess="none" Match="https://*.typingclub.com/" />
|
||||
<uap:Rule Type="include" WindowsRuntimeAccess="none" Match="http://*.typingclub.com/" />
|
||||
{ApplicationContentUriRules}
|
||||
</uap:ApplicationContentUriRules>
|
||||
<uap:VisualElements DisplayName="{AppDisplayName}" Description="{AppDescription}" BackgroundColor="{ThemeColor}" Square150x150Logo="{LogoLarge}" Square44x44Logo="{LogoSmall}">
|
||||
|
|
Загрузка…
Ссылка в новой задаче