[ 
https://issues.apache.org/jira/browse/CB-11195?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15270681#comment-15270681
 ] 

napcat edited comment on CB-11195 at 5/4/16 2:16 PM:
-----------------------------------------------------

I made a cordova hook that run on "after_prepare".

The scripts reads and writes again the .js files on the utf8 encoding system.

I used "iconv-lite" and "glob" as dependencies.

{code:javascript}
#!/usr/bin/env node

module.exports = function(context) 
{
    var path = context.requireCordovaModule('path');
    var fs = context.requireCordovaModule('fs');

    var iconvlite = require('iconv-lite');
    var glob = require("glob");

    var appxManifestPath = path.join(context.opts.projectRoot, 
'\\platforms\\windows\\www\\');

    console.log("AppxManifestPath: " + appxManifestPath);

    if (fs.existsSync(appxManifestPath))
    {
        glob(appxManifestPath + "**/*.js", function (er, files) 
        {
            files.forEach(function(filePath) 
            {
                var file = fs.readFileSync(filePath);

                var buffer = iconvlite.encode(file, "utf8");

                fs.writeFile(filePath, buffer.toString('utf8'), 'utf8', 
function (error)
                {
                    if (error) 
                        throw new error('error saving file as utf8: ' + 
filePath + " " + error);
                });
            });
        });
    }
};
{code}


was (Author: napcat):
I made a cordova hook that run on "after_prepare".

The scripts reads and writes again the .js files on the utf8 encoding system.

I used "iconv-lite" and "glob" as dependencies.

{code:js}
#!/usr/bin/env node

module.exports = function(context) 
{
    var path = context.requireCordovaModule('path');
    var fs = context.requireCordovaModule('fs');

    var iconvlite = require('iconv-lite');
    var glob = require("glob");

    var appxManifestPath = path.join(context.opts.projectRoot, 
'\\platforms\\windows\\www\\');

    console.log("AppxManifestPath: " + appxManifestPath);

    if (fs.existsSync(appxManifestPath))
    {
        glob(appxManifestPath + "**/*.js", function (er, files) 
        {
            files.forEach(function(filePath) 
            {
                var file = fs.readFileSync(filePath);

                var buffer = iconvlite.encode(file, "utf8");

                fs.writeFile(filePath, buffer.toString('utf8'), 'utf8', 
function (error)
                {
                    if (error) 
                        throw new error('error saving file as utf8: ' + 
filePath + " " + error);
                });
            });
        });
    }
};
{code}

> Windows platform - create windows 10 app packages
> -------------------------------------------------
>
>                 Key: CB-11195
>                 URL: https://issues.apache.org/jira/browse/CB-11195
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: Windows
>    Affects Versions: 6.1.1
>            Reporter: napcat
>             Fix For: 6.1.1
>
>
> When a windows cordova platform is added using:
> cordova platform add windows
> And the windows 10 project, inside visual studio 2015, is used to build the 
> app package, the package validation fails, when it's validated using the 
> "Windows App Certification Kit 10.0". The selected architectures are: x86 
> (release), x64(release) and ARM (release).
> {code:xml}
> UTF-8 file encoding
> Error Found: The UTF-8 file encoding test detected the following errors:
> File C:\Program 
> Files\WindowsApps\BECC1407.AppXPTO_1.4.0.0_x64__6hmvhj7j5fc1t\www\cordova_plugins.js
>  is not properly UTF-8 encoded. Re-save the file as UTF-8 (including Byte 
> Order Mark).
> File C:\Program 
> Files\WindowsApps\BECC1407.AppXPTO_1.4.0.0_x64__6hmvhj7j5fc1t\www\cordova-js-src\exec.js
>  is not properly UTF-8 encoded. Re-save the file as UTF-8 (including Byte 
> Order Mark).
> File C:\Program 
> Files\WindowsApps\BECC1407.AppXPTO_1.4.0.0_x64__6hmvhj7j5fc1t\www\cordova-js-src\platform.js
>  is not properly UTF-8 encoded. Re-save the file as UTF-8 (including Byte 
> Order Mark).
> ...
> File C:\Program 
> Files\WindowsApps\BECC1407.AppXPTO_1.4.0.0_x64__6hmvhj7j5fc1t\www\index.html 
> is not properly UTF-8 encoded. Re-save the file as UTF-8 (including Byte 
> Order Mark).
> Impact if not fixed: HTML, CSS, and JavaScript files must be encoded in UTF-8 
> form with a corresponding byte-order mark (BOM) in order to benefit from 
> bytecode caching and to avoid other runtime error conditions.
> {code}
> {code:xml}
> Bytecode generation
> Error Found: The bytecode generation test detected the following errors:
> File \\?\C:\Program 
> Files\WindowsApps\BECC1407.AppXPTO_1.4.0.0_x64__6hmvhj7j5fc1t\www\plugins\cordova-plugin-splashscreen\www\windows\SplashScreenProxy.js
>  has JavaScript syntax or other problems.
> File \\?\C:\Program 
> Files\WindowsApps\BECC1407.AppXPTO_1.4.0.0_x64__6hmvhj7j5fc1t\www\plugins\cordova-plugin-splashscreen\www\splashscreen.js
>  has JavaScript syntax or other problems.
> File \\?\C:\Program 
> Files\WindowsApps\BECC1407.AppXPTO_1.4.0.0_x64__6hmvhj7j5fc1t\www\js\app.min.js
>  has JavaScript syntax or other problems.
> ...
> Impact if not fixed: As a performance optimization to accelerate JavaScript 
> execution time, JavaScript files ending in the ".js" extension generate 
> bytecode when the app is deployed. This optimization significantly improves 
> start-up and ongoing execution times for JavaScript.
> How to fix: You may need consider one or more of these steps to fix the issue:
> - Avoid deploying the app by pressing F5 in Visual Studio, create an appx 
> package instead
> - Ensure that event logging is enabled
> -     All JavaScript files are syntactically valid; otherwise exclude the 
> respective files from the package
> -     Please note that you should uninstall all previous versions of the app 
> before deploying
> Otherwise exclude the respective files from the package.
> {code}
> Can the app be submitted with this erros?
> Should not the cordova generate the project ready for publication?



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to